- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我只在 Lollipop 版本上遇到过这个问题。我可以在 Lollipop 以上的版本上轻松运行该应用程序。当我在我的应用程序文件中运行该应用程序时出现错误:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/picasso/Picasso;
at aroundwise.nepi.MyApplication.onCreate(MyApplication.java:44)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5122)
at android.app.ActivityThread.access$1600(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1510)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.squareup.picasso.Picasso" on path: DexPathList[[zip file "/data/app/aroundwise.nepi-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at aroundwise.nepi.MyApplication.onCreate(MyApplication.java:44)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1020)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5122)
at android.app.ActivityThread.access$1600(ActivityThread.java:177)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1510)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Suppressed: java.lang.ClassNotFoundException: com.squareup.picasso.Picasso
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
这是我的申请文件:
public class MyApplication extends Application {
private static ComplexPreferences sharedPreferences;
public static MyApplication instance;
AroundWiseSDK aroundWiseSDK;
private Picasso picasso;
@Override
public void onCreate() {
super.onCreate();
sharedPreferences = ComplexPreferences.getComplexPreferences(getBaseContext(), Constants.PREFFERENCES, MODE_PRIVATE);
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/ProximaNova-Regular.otf")
.setFontAttrId(R.attr.fontPath)
.build());
Callbacks c = new Callbacks();
instance = this;
HashMap<String, String> clientData = new HashMap<>();
clientData.put("key_placeholder", "value_placeholder");
picasso = Picasso.with(getApplicationContext());
aroundWiseSDK = new AroundWiseSDK(getBaseContext(), this, c, false, "https://promenada.aroundwise.com", clientData);
aroundWiseSDK.setMainActivity(DiscoverActivity.class);
aroundWiseSDK.bindBackgroundService();
}
public Picasso getPicasso() {
return picasso;
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
// MultiDex.install(base);
}
public static ComplexPreferences getSharedPreferences(Context context) {
if (sharedPreferences == null) {
sharedPreferences = ComplexPreferences.getComplexPreferences(context, Constants.PREFFERENCES, MODE_PRIVATE);
}
return sharedPreferences;
}
这是我的gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter()
}
dependencies {
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath 'io.fabric.tools:gradle:1.+'
classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.2'
}
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
apply plugin: 'io.fabric'
apply plugin: 'com.getkeepsafe.dexcount'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 24
buildToolsVersion "25.0.1"
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/BCKEY.DSA'
exclude 'AUTHORS'
exclude 'META-INF/services/javax.annotation.processing.Processor' // butterknife
exclude 'META-INF/BCKEY.SF'
exclude 'META-INF/maven/com.google.guava/guava/pom.properties'
exclude 'META-INF/maven/com.google.guava/guava/pom.xml'
}
defaultConfig {
applicationId "aroundwise.nepi"
minSdkVersion 21
targetSdkVersion 24
versionCode 1
versionName "1.1.8"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
//multiDexKeepFile file('multidex-config.txt')
// multiDexKeepProguard file('multidex-config.pro')
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// multiDexKeepFile file('multidex-config.txt')
// multiDexKeepProguard file('multidex-config.pro')
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def apk = output.outputFile;
def newName;
if (variant.buildType.name == "release") {
newName = apk.name.replace("app-debug", "-release-Nepi" + "-v" + defaultConfig.versionName + ".apk");
} else {
newName = apk.name.replace("app-debug.apk", "-Nepi" + "-v" + defaultConfig.versionName + ".apk");
}
output.outputFile = new File(apk.parentFile, newName);
if (variant.buildType.zipAlignEnabled) {
output.outputFile = new File(apk.parentFile, newName.replace("-unaligned", ""));
}
logger.info('INFO: Set outputFile to ' + output.outputFile + " for [" + variant.name + "]");
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile('com.crashlytics.sdk.android:crashlytics:2.6.2@aar') {
transitive = true;
}
//BUTTERKNIFE
apt 'com.jakewharton:butterknife-compiler:8.2.1'
//MVP & ParcelablePlease & Adapter
apt 'com.hannesdorfmann.annotatedadapter:processor:1.1.1'
apt 'com.hannesdorfmann.parcelableplease:processor:1.0.2'
//AROUNDWISE SDK's
compile(name: 'aroundwisesdk', ext: 'aar')
compile(name: 'aroundwisecards', ext: 'aar')
//GOOGLE
//FACEBOOK
//ANDROID
//RETROFIT&RxANDROID
//UTIL
//compile 'com.lorentzos.swipecards:library:1.0.9@aar'
//BeaconSDk needed
compile 'me.relex:circleindicator:1.1.5@aar'
compile 'com.hannesdorfmann.annotatedadapter:annotation:1.1.1'
compile 'com.hannesdorfmann.annotatedadapter:support-recyclerview:1.1.1'
compile 'com.hannesdorfmann.mosby:mvp:2.0.1'
compile 'com.hannesdorfmann.mosby:viewstate:2.0.1'
compile 'com.hannesdorfmann.parcelableplease:annotation:1.0.2'
compile 'com.hannesdorfmann.mosby:retrofit:1.1.0'
compile 'com.google.gms:google-services:2.1.2'
compile 'com.google.android.gms:play-services-maps:9.4.0'
compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.android.gms:play-services-location:9.4.0'
compile 'com.google.code.gson:gson:2.7'
compile 'com.google.maps.android:android-maps-utils:0.4.4'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:recyclerview-v7:25.0.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-annotations:24.2.1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
compile 'io.reactivex:rxandroid:1.2.0'
compile 'io.reactivex:rxjava:1.1.5'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.jakewharton:butterknife:8.2.1'
compile 'com.github.jinatonic.confetti:confetti:1.0.0'
compile 'com.viewpagerindicator:library:2.4.1@aar'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.3-SNAPSHOT'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0'
compile 'com.github.lzyzsd:circleprogress:1.1.0@aar'
compile 'com.daprlabs.aaron:cardstack:0.3.1-beta0'
compile 'org.altbeacon:android-beacon-library:2.+@aar'
compile 'com.squareup.okhttp:okhttp:2.3.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
apt 'com.google.dagger:dagger-compiler:2.0.2'
compile 'com.google.dagger:dagger:2.0.2'
}
repositories {
flatDir {
dirs 'libs'
}
apply plugin: 'com.google.gms.google-services'
}
这是我的 list 。我正在使用 multidex,但我不需要扩展 MultiDexApplicaiton,因为我使用的是 minSDK 21(至少这是我从文档中了解到的)
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="aroundwise.nepi">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="aroundwise.nepi.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="aroundwise.nepi.permission.C2D_MESSAGE" />
<uses-feature android:name="android.hardware.camera2" />
<application
android:name=".MyApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activities.mainActivity.MainActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="5ef18a8d1003a5ed11bbf50f188bc758133cba38" />
<activity
android:name=".activities.onBoardActivity.OnBoardActivity"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".activities.discoverActivity.DiscoverActivity"
android:screenOrientation="portrait" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_api_key_me" />
<activity
android:name=".activities.cameraActivity.CameraActivity"
android:screenOrientation="portrait" />
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id" />
<provider
android:name="com.facebook.FacebookContentProvider"
android:authorities="com.facebook.app.FacebookContentProvider840752006058179"
android:exported="true" />
<activity
android:name="com.facebook.FacebookActivity"
android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
tools:replace="android:theme" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="aroundwise.nepi.gcm" />
</intent-filter>
</receiver>
<service
android:name=".gcm.PushNotificationListener"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name=".gcm.GcmIdListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID" />
</intent-filter>
</service>
<service
android:name=".gcm.GCMRegistationIntentService"
android:exported="false"></service>
</application>
</manifest>
我没有想法,所以欢迎任何帮助或提示。
谢谢!
最佳答案
如果在 libs build.gradle 中定义了 publishNonDefault true
,请将其删除或设为 false。请尝试。我通过删除发生 NoClassDefFoundError
的 lib 的 build.gradle 中的 publishNonDefault true
解决了这个问题。
如果不行,请添加
dexOptions {
preDexLibraries false
}
关于java - 仅适用于 Lollipop : java. lang.NoClassDefFoundError:解析失败:Lcom/squareup/picasso/Picasso;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41483770/
在 Tomcat 6/Ubuntu 12.04 上启动 Grails 2.1.0 应用程序时出现以下错误。 Error 500 - Internal Server Error. groovy.lang
在运行 Storm 拓扑时,我收到此错误。拓扑完美运行 5 分钟,没有任何错误,然后失败。我正在使用 Config.TOPOLOGY_TICK_TUPLE_FREQ_SECS as 300 sec i
我有一个 jsp 代码在其中一台机器上运行良好。但是当我复制到另一台机器时,我得到了这个 no such method found 异常。我是 Spring 的新手。有人可以解释我错过了什么吗? 以下
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我的代码在下面给出了一个错误; Exception in thread "main" java.lang.NoSuchMethodError: com/myApp/Client.cypherCBC(L
我正在尝试一个 Restful web 服务示例,所以当我要访问 url 时,我遇到了异常 java.lang.NoSuchMethodError: jersey.repackaged.com.goo
我正在将一个 Spring web 项目转换为一个 Maven 项目,但我收到了这个错误: java.lang.NoSuchMethodError: org.jboss.logging.Logger.
在我的项目中,我有一个像这样的枚举: public enum MyEnum { FIRST(1), SECOND(2); private int value; private MyEnum(int v
我创建了这个简单的示例,用于读取 Linux 正常运行时间: public String getMachineUptime() throws IOException { String[] di
我正在使用 Eclipse,并且正在使用 Java。我的目标是使用 bogoSort 方法对 vector 进行排序在一个 vector (vectorExample)中适应我的 vector 类型,
我正在运行以下查询。它显示一条错误消息。如何解决这个错误? ListrouteList=null; List companyList = session.createS
我有以下模型类: @Entity @Table(name="user_content") @org.hibernate.annotations.NamedQueries({ @org.
我有那个错误。这是我的代码: GmailSettingsService service = new GmailSettingsService(APPLICATION_NAME, DOMAIN_NAME
实际上我在执行我的java程序时遇到了下面提到的错误 Exception in thread "pool-1-thread-1" java.lang.ClassCastException: jav
java.lang.ClassCastException: java.lang.Float cannot be cast to java.lang.String 我在以下代码中遇到此异常: Strin
我正在尝试从 linkedhashset 中检索随机元素。下面是我的代码,但它每次都给我异常。 private static void generateRandomUserId(Set userIds
我已经完成了 Android 中的代码: List spinnerArray = new ArrayList(); for (int i = 0; i item = (LinkedTreeMap)
这个问题已经有答案了: Explanation of ClassCastException in Java (12 个回答) 已关闭 6 年前。 我已经编写了 java 到 Json 的代码,同时从页
这个问题在这里已经有了答案: ClassCastException java.lang.Long cannot be cast to clojure.lang.IFn (4 个答案) 关闭 6 年前
我在运行时遇到问题来编译这段代码,这给我一个错误,java.lang.Integer 无法转换为 Java.lang.Double。如果有人帮助我更正此代码,我将非常高兴 double x; pu
我是一名优秀的程序员,十分优秀!