尝试使用Andriod-SocialButtons项目(https://github.com/championswimmer/Android-SocialButtons)中的代码时出现以下异常:
I/art: Rejecting re-init on previously-failed class java.lang.Class<in.championswimmer.libsocialbuttons.BtnSocial>
java.lang.NoClassDefFoundError: in.championswimmer.libsocialbuttons.BtnSocial
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:308)
at java.lang.Class.forName(Class.java:272)
at XXX.onCreate(XXXActivity.java:76)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
这是我的代码段:
Class c;
c = in.championswimmer.libsocialbuttons.Utils.class;
c = in.championswimmer.libsocialbuttons.BuildConfig.class;
c = in.championswimmer.libsocialbuttons.BtnSocial.class;
c = in.championswimmer.libsocialbuttons.SocialFab.class;
此代码段中的前3行执行正常,但我尝试访问它抛出NoClassDefFoundError的BtnSocial或SocialFab类。
BtnSocial和SocialFab类可能不包含任何静态或最终字段或方法。
我正在使用Android Studio开发&amp;运行我的应用程序
这是我的项目build.gradle
:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
和我的应用的build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.22.0'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
}
android {
...
compileSdkVersion 25
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "XXX"
minSdkVersion 16
targetSdkVersion 23
versionCode 9
versionName "2.4"
useLibrary 'org.apache.http.legacy'
}
buildTypes {
...
}
}
dependencies {
...
compile 'com.android.support:support-v4:25.0.1'
compile 'com.google.code.gson:gson:1.7.1'
compile 'com.google.android.gms:play-services-auth:11.8.0'
compile 'com.github.championswimmer:Android-SocialButtons:1.5.0'
...
}
我正在关注Android-SocialButtons的文档:https://github.com/championswimmer/Android-SocialButtons/blob/master/README.md。我错了什么?
答案 0 :(得分:0)
您必须在项目级构建文件中添加jitpack
,而不是在应用级
将您的项目build.gradle
更新为
allprojects {
repositories {
jcenter()
google()
maven { url "https://jitpack.io" }
}
}