検索

ホームページ  >  に質問  >  本文

android - java.lang.NoClassDefFoundError,安卓

昨天好的,今天就不行了,下边的代码报错

WxShareMenu popup = new WxShareMenu(AboutActivity.this);
                popup.showPopupWindow();
java.lang.NoClassDefFoundError: org.pointstone.cugapp.view.WxShareMenu
                                                                           at org.pointstone.cugapp.activities.AboutActivity$5.onClick(AboutActivity.java:188)
                                                                           at android.view.View.performClick(View.java)
                                                                           at android.view.View$PerformClick.run(View.java)
                                                                           at android.os.Handler.handleCallback(Handler.java)
                                                                           at android.os.Handler.dispatchMessage(Handler.java)
                                                                           at android.os.Looper.loop(Looper.java)
                                                                           at android.app.ActivityThread.main(ActivityThread.java)
                                                                           at java.lang.reflect.Method.invokeNative(Native Method)
                                                                           at java.lang.reflect.Method.invoke(Method.java)
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
                                                                           at dalvik.system.NativeStart.main(Native Method)

下边是相关代码,我又新建了两个新的,把代码复制过去还是不行
WxShareMenu.java

package org.pointstone.cugapp.view;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;

import org.pointstone.cugapp.R;

import razerdp.basepopup.BasePopupWindow;

/**
 * Created by Administrator on 2017/3/2.
 */

public class WxShareMenu extends BasePopupWindow implements View.OnClickListener {
    private View popupView;

    public WxShareMenu(Activity context) {
        super(context);
        bindEvent();
    }

    @Override
    protected Animation initShowAnimation() {
        return getTranslateAnimation(250 * 2, 0, 300);
    }

    @Override
    public View getClickToDismissView() {
        return popupView.findViewById(R.id.click_to_dismiss);
    }

    @Override
    public View onCreatePopupView() {
        popupView = LayoutInflater.from(getContext()).inflate(R.layout.wx_share_menu, null);
        return popupView;
    }

    @Override
    public View initAnimaView() {
        return popupView.findViewById(R.id.popup_anima);
    }

    private void bindEvent() {
        if (popupView != null) {
            popupView.findViewById(R.id.tx_1).setOnClickListener(this);
            popupView.findViewById(R.id.tx_2).setOnClickListener(this);
            popupView.findViewById(R.id.tx_3).setOnClickListener(this);
        }

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tx_1:

                break;
            case R.id.tx_2:

                break;
            case R.id.tx_3:

                break;
            default:
                break;
        }

    }
}

wx_share_menu.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <RelativeLayout
        android:id="@+id/click_to_dismiss"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/share_popup_bg"
        >

        <LinearLayout
            android:id="@+id/popup_anima"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_alignParentBottom="true"
            android:background="@android:color/white"
            >
            <TextView
                android:id="@+id/tx_1"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:gravity="center"
                android:text="分享到朋友圈"/>
            <View
                style="@style/line_style"/>
            <TextView
                android:id="@+id/tx_2"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:gravity="center"
                android:text="分享给微信好友"/>
            <View
                style="@style/line_style"/>
            <TextView
                android:id="@+id/tx_3"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:gravity="center"
                android:text="取消"/>

        </LinearLayout>
    </RelativeLayout>

</RelativeLayout>
defaultConfig {
        applicationId "org.pointstone.cugapp"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 10
        versionName "1.0.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }

求解决,我要崩溃

PHPzPHPz2893日前645

全員に返信(3)返信します

  • 高洛峰

    高洛峰2017-04-18 09:15:40

    65536 を超える関数があります、http://www.jianshu.com/p/2450...

    返事
    0
  • PHPz

    PHPz2017-04-18 09:15:40

    実際、あなたの clear プロジェクトは一般的には良いと思います。 Popupwindow は XML で書かれておらず、完全なパッケージ名が必要です。しかし、Android Studio の場合は問題がありません。これは開発中によく発生しますが、Clear 或 Restart(Pc/Android Studio)
    です。

    返事
    0
  • PHPz

    PHPz2017-04-18 09:15:40

    このエラーは通常、実行環境がクラスを見つけられないか、または一般的なコントロールでの定義されたクラスの作成が失敗することが原因で発生します。コントロール内で必要なリソースが見つからないことが原因である可能性があります。 attrs.xml 、drawables などのファイルに依存するため、jar のみに依存するか、jar のみに依存する場合は aar (完全な andorid プロジェクト ライブラリ) に依存するかにかかわらず、インポートした参照ライブラリの整合性を確認する必要があります。場合によっては、依存関係を再度変更する必要があります。

    返事
    0
  • キャンセル返事