I am using the Fabric API and the twitter Kit for my application and I get always get an error only for some build versions.
In my case on the API 19 I get an error on:
Fabric.with(this, new Twitter(authConfig));
Here is the error
java.lang.NoClassDefFoundError: retrofit2.Retrofit$Builder
at com.twitter.sdk.android.core.internal.oauth.OAuthService.<init>(OAuthService.java:69)
at com.twitter.sdk.android.core.internal.oauth.OAuth2Service.<init>(OAuth2Service.java:59)
at com.twitter.sdk.android.core.TwitterCore.createGuestSessionProvider(TwitterCore.java:223)
at com.twitter.sdk.android.core.TwitterCore.getGuestSessionProvider(TwitterCore.java:216)
at com.twitter.sdk.android.tweetui.TweetUi.onPreExecute(TweetUi.java:77)
at io.fabric.sdk.android.InitializationTask.onPreExecute(InitializationTask.java:44)
at io.fabric.sdk.android.services.concurrency.AsyncTask.executeOnExecutor(AsyncTask.java:611)
at io.fabric.sdk.android.services.concurrency.PriorityAsyncTask.executeOnExecutor(PriorityAsyncTask.java:43)
at io.fabric.sdk.android.Kit.initialize(Kit.java:69)
at io.fabric.sdk.android.Fabric.initializeKits(Fabric.java:439)
at io.fabric.sdk.android.Fabric.init(Fabric.java:383)
at io.fabric.sdk.android.Fabric.setFabric(Fabric.java:341)
at io.fabric.sdk.android.Fabric.with(Fabric.java:312)
at com.lmst.runnincity.Model.SkobblerAddOn.onCreate(SkobblerAddOn.java:39)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4446)
at android.app.ActivityThread.access$1500(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1302)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5124)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:797)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:613)
at dalvik.system.NativeStart.main(Native Method)
Here is my build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.**********"
minSdkVersion 15
targetSdkVersion 24
versionCode 2
versionName "1.1.1"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
}
sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.google.code.gson:gson:2.7'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-database:9.2.0'
compile 'com.google.firebase:firebase-storage:9.2.0'
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.wx.wheelview:wheelview:1.3.3'
compile project(':sdktools')
compile 'com.google.android.gms:play-services-appindexing:9.2.0'
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
compile 'com.github.lzyzsd:circleprogress:1.1.0#aar'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile('com.twitter.sdk.android:twitter:2.0.0#aar') {
compile('com.twitter.sdk.android:tweet-composer:2.0.0#aar') {
transitive = true;
}
transitive = true;
}
}
apply plugin: 'com.google.gms.google-services'
Try to include support for multidex https://developer.android.com/studio/build/multidex.html
and my dependencies is simple as for Crashlytics:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.crashlytics.sdk.android:crashlytics:2.6.6#aar') {
transitive = true;
}
compile('com.twitter.sdk.android:twitter:2.3.1#aar') {
transitive = true;
}
...
compile 'com.android.support:multidex:1.0.1'
}
Related
environment
Android Studio version: 3.4.2
problem
When I add apply plugin in gradle, the build failed.
I've added a firebase performance sdk according to the guidelines.
and, If minify is enabled(buildtype : release), there is no problem the build. However, the build failed when minify is disabled(buildtype : debug). While testing, I founded that the build was successful by removing the line apply plugin: 'com.google.firebase.firebase-perf'.
build.gradle(project level)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
kotlin_version = '1.3.41'
nav_version = '2.1.0-alpha05'
kodein_version = '6.3.3'
debug_drawer_version = '0.7.0'
stetho_version = '1.5.0'
glide_version = '4.9.0'
okhttp3_version = '3.10.0'
retrofit_version = '2.6.0'
gson_version = '2.8.5'
lifecycle_version = '2.2.0-alpha01'
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'io.realm:realm-gradle-plugin:5.8.0'
classpath 'com.google.gms:google-services:4.3.0'
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath 'com.google.firebase:perf-plugin:1.3.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(app level)
apply plugin: 'com.google.firebase.firebase-perf' // if remove this line, build successful
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
apply from: '../jacoco.gradle'
apply plugin: "androidx.navigation.safeargs.kotlin"
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId ...
targetSdkVersion 28
minSdkVersion 19
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/rxjava.properties'
exclude 'META-INF/atomicfu.kotlin_module'
exclude 'lib/arm64-v8a/libcardioDecider.so'
exclude 'lib/arm64-v8a/libcardioRecognizer.so'
exclude 'lib/arm64-v8a/libcardioRecognizer_tegra2.so'
exclude 'lib/arm64-v8a/libopencv_core.so'
exclude 'lib/arm64-v8a/libopencv_imgproc.so'
exclude 'lib/armeabi/libcardioDecider.so'
exclude 'lib/armeabi-v7a/libcardioDecider.so'
exclude 'lib/armeabi-v7a/libcardioRecognizer.so'
exclude 'lib/armeabi-v7a/libcardioRecognizer_tegra2.so'
exclude 'lib/armeabi-v7a/libopencv_core.so'
exclude 'lib/armeabi-v7a/libopencv_imgproc.so'
exclude 'lib/mips/libcardioDecider.so'
exclude 'lib/x86/libcardioDecider.so'
exclude 'lib/x86/libcardioRecognizer.so'
exclude 'lib/x86/libcardioRecognizer_tegra2.so'
exclude 'lib/x86/libopencv_core.so'
exclude 'lib/x86/libopencv_imgproc.so'
exclude 'lib/x86_64/libcardioDecider.so'
exclude 'lib/x86_64/libcardioRecognizer.so'
exclude 'lib/x86_64/libcardioRecognizer_tegra2.so'
exclude 'lib/x86_64/libopencv_core.so'
exclude 'lib/x86_64/libopencv_imgproc.so'
}
dataBinding.enabled = true
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "4g"
maxProcessCount 8
}
kapt {
correctErrorTypes = true
useBuildCache = true
javacOptions {
// Increase the max count of errors from annotation processors.
// Default is 100.
option("-Xmaxerrs", 500)
}
}
lintOptions {
abortOnError false
}
signingConfigs {
release {
...
}
}
buildTypes {
debug {
debuggable true
}
debugRelease {
minifyEnabled true
testCoverageEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
matchingFallbacks = ['debug']
}
snapshot {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
matchingFallbacks = ['debug']
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
flavorDimensions "region"
productFlavors {
global {
...
}
china {
...
}
}
sourceSets {
...
}
applicationVariants.all { variant ->
...
}
}
def getStoreName(flavorName) {
...
}
def getDate() {
...
}
configurations.all {
...
}
dependencies {
// module
api project(path: ':base')
api project(path: ':entity')
implementation fileTree(dir: 'libs', include: ['*.jar'])
// AndroidX
androidTestImplementation 'androidx.annotation:annotation:1.0.0'
androidTestImplementation 'androidx.test:runner:1.1.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.percentlayout:percentlayout:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'androidx.browser:browser:1.0.0'
implementation 'androidx.paging:paging-runtime:2.1.0'
implementation 'androidx.core:core-ktx:1.0.2'
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.0'
// Google Services
implementation 'com.google.android.material:material:1.1.0-alpha03'
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-dynamic-links:18.0.0'
implementation 'com.google.firebase:firebase-perf:18.0.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.google.android.gms:play-services-base:17.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-analytics:17.0.0'
implementation 'com.google.android.libraries.places:places:2.0.0'
// Network Library
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp3_version"
implementation "com.squareup.okhttp3:okhttp-urlconnection:$okhttp3_version"
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava:$retrofit_version"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
implementation('org.apache.httpcomponents:httpmime:4.3.6') { exclude module: 'httpclient' }
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5'
implementation 'com.android.volley:volley:1.1.1'
// Rx2
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.12'
implementation 'io.reactivex.rxjava2:rxkotlin:2.2.0'
implementation 'com.jakewharton.rxbinding2:rxbinding:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-support-v4:2.1.1'
implementation 'com.jakewharton.rxbinding2:rxbinding-recyclerview-v7:2.1.1'
// View
implementation 'me.grantland:autofittextview:0.2.1'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
implementation 'com.wang.avi:library:2.1.3'
implementation 'com.facebook.shimmer:shimmer:0.2.0'
// Image Loader
implementation "com.github.bumptech.glide:glide:$glide_version"
// SNS
implementation('com.twitter.sdk.android:twitter-core:3.3.0#aar') { transitive = true }
// Debug
implementation "com.facebook.stetho:stetho:$stetho_version"
implementation "com.facebook.stetho:stetho-okhttp3:$stetho_version"
implementation 'com.uphyca:stetho_realm:2.2.2'
debugImplementation "io.palaima.debugdrawer:debugdrawer:$debug_drawer_version"
debugReleaseImplementation "io.palaima.debugdrawer:debugdrawer:$debug_drawer_version"
releaseImplementation "io.palaima.debugdrawer:debugdrawer-no-op:$debug_drawer_version"
snapshotImplementation "io.palaima.debugdrawer:debugdrawer-no-op:$debug_drawer_version"
implementation "io.palaima.debugdrawer:debugdrawer-commons:$debug_drawer_version"
// QR Code Reader
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
// Test
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.4'
testImplementation 'org.json:json:20180813'
testImplementation 'org.testng:testng:6.14.3'
// Payment
implementation('com.paypal.sdk:paypal-android-sdk:2.16.0') { exclude group: 'io.card' }
// Crash Report
implementation('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') { transitive = true }
// App Rebirth
implementation 'com.jakewharton:process-phoenix:2.0.0'
// Dependencies Only for Global
globalImplementation fileTree(dir: 'src/global/libs', include: ['*.jar'])
globalImplementation 'com.google.android.gms:play-services-identity:17.0.0'
globalImplementation 'com.google.android.gms:play-services-plus:17.0.0'
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
globalImplementation 'com.google.firebase:firebase-messaging:19.0.1'
// Dependencies Only For China
chinaImplementation fileTree(dir: 'src/china/libs', include: ['*.jar'])
chinaImplementation project(':libraries:weiboSDK')
chinaImplementation 'com.umeng.analytics:analytics:latest.integration' // china analytics
chinaImplementation 'me.pushy:sdk:1.0.27'
// Permission
implementation 'com.karumi:dexter:4.2.0'
implementation 'com.otaliastudios:cameraview:1.6.1'
// Logging
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:9.0.1'
// Navigation
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
implementation 'com.appsflyer:af-android-sdk:4.10.0'
implementation 'com.android.installreferrer:installreferrer:1.0'
}
androidExtensions { experimental = true }
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
repositories {
flatDir { dirs 'libs' }
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://github.com/WickeDev/stetho-realm/raw/master/maven-repo' }
maven { url 'https://maven.google.com' }
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
Exception log
> Task :app:transformClassesWithMultidexlistForChinaDebug
AGPBI: {"kind":"error","text":"Cannot fit requested classes in the main-dex file (# methods: 68027 \u003e 65536)","sources":[{}],"tool":"D8"}
> Task :app:transformDexArchiveWithDexMergerForChinaDebug FAILED
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
at sun.reflect.GeneratedConstructorAccessor639.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.util.concurrent.ForkJoinTask.getThrowableException(ForkJoinTask.java:593)
at java.util.concurrent.ForkJoinTask.reportException(ForkJoinTask.java:677)
at java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:720)
at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:407)
at com.android.build.gradle.internal.transforms.DexMergerTransform.transform(DexMergerTransform.java:244)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:239)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:235)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:230)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:103)
at org.gradle.api.internal.project.taskfactory.IncrementalTaskInputsTaskAction.doExecute(IncrementalTaskInputsTaskAction.java:46)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:41)
at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:28)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$5.run(ExecuteActionsTaskExecuter.java:401)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:402)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:394)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:92)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:390)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:373)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$200(ExecuteActionsTaskExecuter.java:79)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:210)
at org.gradle.internal.execution.steps.ExecuteStep.lambda$execute$0(ExecuteStep.java:32)
at java.util.Optional.map(Optional.java:215)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:32)
at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:26)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:58)
at org.gradle.internal.execution.steps.CleanupOutputsStep.execute(CleanupOutputsStep.java:35)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:33)
at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:39)
at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:73)
at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:54)
at org.gradle.internal.execution.steps.CatchExceptionStep.execute(CatchExceptionStep.java:35)
at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:45)
at org.gradle.internal.execution.steps.SnapshotOutputsStep.execute(SnapshotOutputsStep.java:31)
at org.gradle.internal.execution.steps.CacheStep.executeWithoutCache(CacheStep.java:201)
at org.gradle.internal.execution.steps.CacheStep.executeAndStoreInCache(CacheStep.java:183)
at org.gradle.internal.execution.steps.CacheStep.lambda$executeWithCache$2(CacheStep.java:106)
at java.util.Optional.orElseGet(Optional.java:267)
at org.gradle.internal.execution.steps.CacheStep.lambda$executeWithCache$3(CacheStep.java:106)
at org.gradle.internal.Try$1.apply(Try.java:59)
at org.gradle.internal.Try$1.apply(Try.java:56)
at org.gradle.internal.Try$Success.flatMap(Try.java:102)
at org.gradle.internal.Try.map(Try.java:56)
at org.gradle.internal.execution.steps.CacheStep.executeWithCache(CacheStep.java:79)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:69)
at org.gradle.internal.execution.steps.CacheStep.execute(CacheStep.java:45)
at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:49)
at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:43)
at org.gradle.internal.execution.steps.StoreSnapshotsStep.execute(StoreSnapshotsStep.java:32)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:38)
at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:24)
at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:96)
at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:89)
at java.util.Optional.map(Optional.java:215)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:54)
at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:77)
at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:37)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:36)
at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:26)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:90)
at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:48)
at org.gradle.internal.execution.impl.DefaultWorkExecutor.execute(DefaultWorkExecutor.java:33)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:117)
at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionStateTaskExecuter.execute(ResolveBeforeExecutionStateTaskExecuter.java:75)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:108)
at org.gradle.api.internal.tasks.execution.ResolveBeforeExecutionOutputsTaskExecuter.execute(ResolveBeforeExecutionOutputsTaskExecuter.java:67)
at org.gradle.api.internal.tasks.execution.StartSnapshotTaskInputsBuildOperationTaskExecuter.execute(StartSnapshotTaskInputsBuildOperationTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.ResolveAfterPreviousExecutionStateTaskExecuter.execute(ResolveAfterPreviousExecutionStateTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:94)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:95)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:73)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:49)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:416)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:406)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$1.execute(DefaultBuildOperationExecutor.java:165)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:250)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:158)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:102)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:49)
at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:355)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:343)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:336)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:322)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1431)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:131)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:118)
at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:102)
at com.android.build.gradle.internal.transforms.DexMergerTransformCallable.call(DexMergerTransformCallable.java:37)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
... 4 more
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:81)
at com.android.tools.r8.utils.ExceptionUtils.withD8CompilationHandler(ExceptionUtils.java:45)
at com.android.tools.r8.D8.run(D8.java:94)
at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:116)
... 7 more
Caused by: com.android.tools.r8.utils.AbortException: Error: null, Cannot fit requested classes in the main-dex file (# methods: 68027 > 65536)
at com.android.tools.r8.utils.Reporter.failIfPendingErrors(Reporter.java:101)
at com.android.tools.r8.utils.Reporter.fatalError(Reporter.java:72)
at com.android.tools.r8.dex.VirtualFile.throwIfFull(VirtualFile.java:193)
at com.android.tools.r8.dex.VirtualFile$DistributorBase.fillForMainDexList(VirtualFile.java:328)
at com.android.tools.r8.dex.VirtualFile$FillFilesDistributor.run(VirtualFile.java:380)
at com.android.tools.r8.dex.ApplicationWriter.distribute(ApplicationWriter.java:200)
at com.android.tools.r8.dex.ApplicationWriter.write(ApplicationWriter.java:221)
at com.android.tools.r8.D8.run(D8.java:215)
at com.android.tools.r8.D8.lambda$run$1(D8.java:97)
at com.android.tools.r8.utils.ExceptionUtils.withCompilationHandler(ExceptionUtils.java:62)
... 10 more
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForChinaDebug'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
BUILD FAILED in 1m 3s
82 actionable tasks: 12 executed, 70 up-to-date
Why is this happening?
It looks like your method count has exceeded that limit for a single dex which frequently occurs on complex apps that include multiple libraries.
See this question about multi-dex:
What is Android MultiDex?
I have included Realm in a project, and have followed the documentation. But whenever I compile and run the app, i get the following error:
FATAL EXCEPTION: main
Process: org.innoversetech.wifinity, PID: 8391
java.lang.NoSuchMethodError: No static method loadLibrary(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V in class Lcom/getkeepsafe/relinker/ReLinker; or its super classes (declaration of 'com.getkeepsafe.relinker.ReLinker' appears in /data/app/org.innoversetech.wifinity-2/split_lib_dependencies_apk.apk:classes16.dex)
at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:60)
at io.realm.Realm.init(Realm.java:200)
at org.innoversetech.wifinity.MyApplication.onCreate(MyApplication.java:17)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6496)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
I have been at this for hours now and I cannot understand what the problem is. Here is my code for MyApplication class:
import android.app.Application;
import io.realm.Realm;
import io.realm.RealmConfiguration;
public class MyApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Realm.init(getApplicationContext());
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.name(Realm.DEFAULT_REALM_NAME)
.schemaVersion(0)
.deleteRealmIfMigrationNeeded()
.build();
Realm.setDefaultConfiguration(realmConfiguration);
}
}
This is my build.gradle for app level:
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
repositories {
maven {
url "https://jitpack.io"
}
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "org.innoversetech.wifinity"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
proguardFile 'D:/Code/Android/KillMe/Wifinity/app/proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//dependencies
compile('com.mikepenz:materialdrawer:5.9.5#aar') {
transitive = true
}
compile 'devlight.io:navigationtabbar:1.2.5'
compile 'devlight.io:navigationtabbar:1.2.5'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.github.florent37:materialviewpager:1.2.1'
compile 'com.flaviofaria:kenburnsview:1.0.7'
compile 'com.jpardogo.materialtabstrip:library:1.1.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.jakewharton:butterknife:8.6.0'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.mani:ThinDownloadManager:1.3.0'
compile 'com.github.barteksc:android-pdf-viewer:2.6.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.afollestad.material-dialogs:core:0.9.4.5'
compile 'com.afollestad.material-dialogs:commons:0.9.4.5'
compile 'com.felipecsl.asymmetricgridview:library:2.0.1'
compile 'com.race604.waveloading:library:1.1.1'
compile 'com.github.Yalantis:GuillotineMenu-Android:1.2'
compile 'net.steamcrafted:materialiconlib:1.1.3'
compile 'com.mikepenz:google-material-typeface:+#aar'
compile 'com.mikepenz:fontawesome-typeface:+#aar'
compile 'com.diegodobelo.expandingview:expanding-view:0.9.4'
compile 'com.github.thorbenprimke:realm-recyclerview:0.9.25'
compile 'it.sephiroth.android.library.targettooltip:target-tooltip-library:1.3.15'
compile 'com.getkeepsafe.relinker:relinker:1.2.2'
compile 'com.github.KeepSafe:ReLinker:1.1'
testCompile 'junit:junit:4.12'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '26.0.0-alpha1'
}
}
}
}
And this is the project level gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven{
url "https://jitpack.io"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "io.realm:realm-gradle-plugin:3.5.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
This is the error I get when I remove the ReLinker libraries:
Process: org.innoversetech.wifinity, PID: 22788
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/getkeepsafe/relinker/ReLinker;
at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:60)
at io.realm.Realm.init(Realm.java:200)
at org.innoversetech.wifinity.MyApplication.onCreate(MyApplication.java:17)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6496)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.getkeepsafe.relinker.ReLinker" on path: DexPathList[[zip file "/data/app/org.innoversetech.wifinity-1/base.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_dependencies_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_0_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_1_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_2_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_3_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_4_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_5_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_6_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_7_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_8_apk.apk", zip file "/data/app/org.innoversetech.wifinity-1/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/org.innoversetech.wifinity-1/lib/arm, /data/app/org.innoversetech.wifinity-1/base.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_dependencies_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_0_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_1_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_2_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_3_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_4_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_5_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_6_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_7_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_8_apk.apk!/lib/armeabi-v7a, /data/app/org.innoversetech.wifinity-1/split_lib_slice_9_apk.apk!/lib/armeabi-v7a, /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 io.realm.internal.RealmCore.loadLibrary(RealmCore.java:60)
at io.realm.Realm.init(Realm.java:200)
at org.innoversetech.wifinity.MyApplication.onCreate(MyApplication.java:17)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1037)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6496)
at android.app.ActivityThread.access$1800(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7406)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Suppressed: java.lang.ClassNotFoundException: com.getkeepsafe.relinker.ReLinker
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)
... 14 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Realm depends on implementation 'com.getkeepsafe.relinker:relinker:1.2.2' (basically "compile"), but I think your issue is caused by
compile 'com.github.thorbenprimke:realm-recyclerview:0.9.25'
Because version 0.9.25 brings in Realm version 2.2.1, so that can clash against Realm 3.5.0.
A possible solution would be to copy the sources of RealmBasedRecyclerViewAdapter to your code so that it doesn't depend on old things.
Another thing you can do is just not use RealmBasedRecyclerViewAdapter, and give a try for RealmRecyclerViewAdapter in realm-android-adapters.
A clean+rebuild might also help.
in your onCreate use,
realmConfiguration = new RealmConfiguration.Builder().build();
realm = Realm.getInstance(realmConfiguration);
There's giving me following error in my demo app:
FATAL EXCEPTION: main
Process: com.example.android.pos_api_android_demo, PID: 9359
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app-lib/com.example.android.pos_api_android_demo-13/libPosAPI.so" not 32-bit: 2
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:526)
at com.vatps.android.PosAPI.<clinit>(PosAPI.java:35)
at com.example.android.pos_api_android_demo.MainActivity$1.onClick(MainActivity.java:23)
at android.view.View.performClick(View.java:4867)
at android.view.View$PerformClick.run(View.java:19722)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5756)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Yes , libPosAPI.so file is 64 bit. There are solution like this. [https://bugs.chromium.org/p/webrtc/issues/detail?id=4186][1]
[1]: https://bugs.chromium.org/p/webrtc/issues/detail?id=4186 But this is for linux user. I'm using Windows. and old topic is all about error:32 bit instead 64.
My Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.example.android.pos_api_android_demo"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets.main {
jniLibs.srcDirs = ['libs']
jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk file }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
testCompile 'junit:junit:4.12'
}
Project Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
//compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.google.android.gms:play-services:9.8.0'
compile 'com.google.firebase:firebase-core:9.8.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Activity:
private DatabaseReference mDatabase;
...
mDatabase = FirebaseDatabase.getInstance().getReference(Config.FIREBASE_URL); //public static final String FIREBASE_URL = "https://myapp.firebaseio.com/ ";
...
mDatabase.setValue(edittextName.getText().toString());
Class:
public class Config {
public static final String FIREBASE_URL = "https://myapps.firebaseio.com/ ";
}
I am getting the following error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp, PID: 30211
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.MainActivity}: com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: FirebaseApp object has no DatabaseURL in its FirebaseOptions object.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2316)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.access$800(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5253)
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)
Caused by: com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: FirebaseApp object has no DatabaseURL in its FirebaseOptions object.
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.myapp.MainActivity.onCreate(MainActivity.java:103)
at android.app.Activity.performCreate(Activity.java:5975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.access$800(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5253)
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)
How can I resolve the issue.
The link provided does not resolve my issue!
Per #qbix, I had to use getReferenceFromUrl() and the app didn't crash.
I can't understand where have i gone wrong in setting up firebase realtime database. I have followed the steps given on firebase docs and hence don't understand why this issue rose. Can't figure what's gone wrong??
My crash log :
FATAL EXCEPTION: main
Process: co.stemapps.alpha, PID: 16807
java.lang.NoSuchMethodError: No static method zzeq(Landroid/content/Context;)Lcom/google/android/gms/internal/zzalp; in class Lcom/google/android/gms/internal/zzalp; or its super classes (declaration of 'com.google.android.gms.internal.zzalp' appears in /data/data/co.stemapps.alpha/files/instant-run/dex/slice-com.google.firebase-firebase-database-9.2.1_4a374bd9658b1411c8c3a3826ddeec88e7022694-classes.dex)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.zzek(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1730)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1705)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5039)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4634)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4574)
at android.app.ActivityThread.access$1600(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1382)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5294)
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:904)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)
build.gradle :
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "co.stemapps.alpha"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile('com.twitter.sdk.android:twitter-core:1.6.6#aar') {
transitive = true
}
compile('com.twitter.sdk.android:twitter:1.13.1#aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.github.scottyab:showhidepasswordedittext:0.8'
compile 'com.mikhaellopez:circularimageview:3.0.2'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.+'
compile 'com.squareup.dagger:dagger:1.2.2'
compile 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
}
apply plugin: 'com.google.gms.google-services'
Can anyone help me fix it?