android - java.lang.NoClassDefFoundError,安卓
問題描述
昨天好的,今天就不行了,下邊的代碼報(bào)錯(cuò)
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)
下邊是相關(guān)代碼,我又新建了兩個(gè)新的,把代碼復(fù)制過去還是不行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'> <RelativeLayoutandroid: android:layout_width='match_parent'android:layout_height='match_parent'android:background='@color/share_popup_bg'><LinearLayout android: android:layout_width='match_parent' android:layout_height='wrap_content' android:orientation='vertical' android:layout_alignParentBottom='true' android:background='@android:color/white' > <TextViewandroid: android:layout_width='match_parent'android:layout_height='60dp'android:gravity='center'android:text='分享到朋友圈'/> <View /> <TextViewandroid: android:layout_width='match_parent'android:layout_height='60dp'android:gravity='center'android:text='分享給微信好友'/> <View /> <TextViewandroid: android:layout_width='match_parent'android:layout_height='60dp'android:gravity='center'android:text='取消'/></LinearLayout> </RelativeLayout></RelativeLayout>
defaultConfig {applicationId 'org.pointstone.cugapp'minSdkVersion 16targetSdkVersion 24versionCode 10versionName '1.0.1'testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'multiDexEnabled true }
求解決,我要崩潰
問題解答
回答1:函數(shù)超過 65536 個(gè)了,http://www.jianshu.com/p/2450...
回答2:其實(shí)我覺得,你clear下項(xiàng)目一般都會(huì)好,你的Popupwindow又不是一般的寫在xml中需要完整包名,我沒發(fā)現(xiàn)你的寫法有問題,倒是Android Studio經(jīng)常不把你寫的代碼打包到apk中,開發(fā)中經(jīng)常遇到,一半Clear 或 Restart(Pc/Android Studio)可解決.
這個(gè)錯(cuò)誤一般是由于運(yùn)行環(huán)境找不到類或者定義的類創(chuàng)建失敗所造成,一般控件中出現(xiàn)這個(gè)錯(cuò)誤可能是由于該控件中某些所需的資源無法找到的原因,如attrs.xml,drawables等等,所以你需要確認(rèn)你導(dǎo)入的引用的library的完整性,是僅僅只是依賴了一個(gè)jar還是一個(gè)aar(一個(gè)完整的andorid工程庫),若只是依賴jar的話,可能需要重新修改下依賴.
相關(guān)文章:
1. android - 請(qǐng)教安卓的一個(gè)界面實(shí)現(xiàn),圖片請(qǐng)看問題2. css3安卓下效果卡3. javascript - web移動(dòng)端 ? 版權(quán)這個(gè)字在安卓上默認(rèn)藍(lán)色顏色 怎么解決?4. java - 學(xué)習(xí)做一個(gè)安卓視頻播放器,有一些小問題!忘大家請(qǐng)教5. java - 學(xué)習(xí)做一個(gè)安卓視頻播放器,想實(shí)現(xiàn)一個(gè)功能,遇到問題!6. android - 優(yōu)酷的安卓及蘋果app還在使用flash技術(shù)嗎?7. android-studio - 一直無法下載android studio的 安卓模擬器求助8. java - 新手做一個(gè)安卓視頻播放器,想實(shí)現(xiàn)一個(gè)進(jìn)度條,按鈕那種在視頻下方懸浮的功能,不知道思路!9. css - Sprites雪碧圖,安卓機(jī)緩存問題10. angular.js - angurlarJS的安卓的微信端中用加載ngCookies會(huì)出錯(cuò)的問題
