Reputation: 101
So I am currently trying to import multidex into my project, I have followed the provided documentations/QnA Android Application using Firebase database keeps crashing when launching?
https://developer.android.com/studio/build/multidex#java
and have done the following amends to my build.gradle app file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.finalyearprojectapp"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
multiDexKeepFile file('multidex-config.txt')
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation "androidx.multidex:multidex:2.0.1"
//implementation 'com.android.support:multidex:1.0.3'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-firestore:22.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
I have followed the documentation until it has mentioned that I am needed to implement the following code into my android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp">
<application
android:name="androidx.multidex.MultiDexApplication" >
...
</application>
</manifest>
I have added this to the manifest, my XML:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.finalyearprojectapp">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name="androidx.multidex.MultiDexApplication" >
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainScreen" />
<activity android:name=".RegisterActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
But now I run across this error
Failed to parse XML in C:\Users\jabze\Desktop\FinalApp\app\src\main\AndroidManifest.xml
ParseError at [row,col]:[11,43]
Message: expected start or end tag
Affected Modules: app
I have done literally every tutorial out there and I just cannot figure out the issue, i feel like giving up on this project.
I have tried extending it from each class as mentioned in documentation and all my code has errors to resolve, some with no context.
I have tried extending it using a base class which uses multidex and then trying to add it into the android manifest like this,
android:name=".BaseApp"
Then creating a class to extend from multidex
import androidx.multidex.MultiDexApplication;
public class BaseApp extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
}
}
This has solved the configuration problem, but now i recieve a error when trying to open my app, logcat
2021-03-29 00:28:45.035 31916-31916/? I/lyearprojectap: Not late-enabling -Xcheck:jni (already on)
2021-03-29 00:28:45.054 31916-31916/? I/lyearprojectap: Unquickening 12 vdex files!
2021-03-29 00:28:45.055 31916-31916/? W/lyearprojectap: Unexpected CPU variant for X86 using defaults: x86
2021-03-29 00:28:45.150 31916-31916/com.example.finalyearprojectapp D/ApplicationLoaders: Returning zygote-cached class loader: /system/framework/android.test.base.jar
2021-03-29 00:28:45.395 31916-31916/com.example.finalyearprojectapp D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2021-03-29 00:28:45.395 31916-31916/com.example.finalyearprojectapp D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2021-03-29 00:28:45.398 31916-31916/com.example.finalyearprojectapp I/MultiDex: VM with version 2.1.0 has multidex support
2021-03-29 00:28:45.398 31916-31916/com.example.finalyearprojectapp I/MultiDex: Installing application
2021-03-29 00:28:45.399 31916-31916/com.example.finalyearprojectapp I/MultiDex: VM has multidex support, MultiDex support library is disabled.
2021-03-29 00:28:45.419 31916-31916/com.example.finalyearprojectapp W/ComponentDiscovery: Class com.google.firebase.dynamicloading.DynamicLoadingRegistrar is not an found.
2021-03-29 00:28:45.435 31916-31916/com.example.finalyearprojectapp I/FirebaseApp: Device unlocked: initializing all Firebase APIs for app [DEFAULT]
2021-03-29 00:28:45.529 31916-31977/com.example.finalyearprojectapp W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2021-03-29 00:28:45.564 31916-31916/com.example.finalyearprojectapp D/FirebaseAuth: Notifying id token listeners about user ( v9NWiRcvjMTz4y8V8kXy6f7RZdQ2 ).
2021-03-29 00:28:45.566 31916-31916/com.example.finalyearprojectapp D/AndroidRuntime: Shutting down VM
2021-03-29 00:28:45.567 31916-31916/com.example.finalyearprojectapp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.finalyearprojectapp, PID: 31916
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp$IdTokenListenersCountChangedListener;
at com.google.firebase.auth.zzp.create(Unknown Source:3)
at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0(ComponentRuntime.java:132)
at com.google.firebase.components.ComponentRuntime$$Lambda$1.get(Unknown Source:4)
at com.google.firebase.components.Lazy.get(Lazy.java:53)
at com.google.firebase.components.ComponentRuntime.doInitializeEagerComponents(ComponentRuntime.java:291)
at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(ComponentRuntime.java:281)
at com.google.firebase.FirebaseApp.initializeAllApis(FirebaseApp.java:584)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:303)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:7239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.FirebaseApp$IdTokenListenersCountChangedListener" on path: DexPathList[[zip file "/data/app/~~yUZ3UTW9uE5Wv9gw7MBIVA==/com.example.finalyearprojectapp-ZqPMbXUiTbtxIQSglqq2dg==/base.apk"],nativeLibraryDirectories=[/data/app/~~yUZ3UTW9uE5Wv9gw7MBIVA==/com.example.finalyearprojectapp-ZqPMbXUiTbtxIQSglqq2dg==/lib/x86, /system/lib, /system_ext/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.google.firebase.auth.zzp.create(Unknown Source:3)
at com.google.firebase.components.ComponentRuntime.lambda$discoverComponents$0(ComponentRuntime.java:132)
at com.google.firebase.components.ComponentRuntime$$Lambda$1.get(Unknown Source:4)
at com.google.firebase.components.Lazy.get(Lazy.java:53)
at com.google.firebase.components.ComponentRuntime.doInitializeEagerComponents(ComponentRuntime.java:291)
at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(ComponentRuntime.java:281)
at com.google.firebase.FirebaseApp.initializeAllApis(FirebaseApp.java:584)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:303)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:267)
at com.google.firebase.FirebaseApp.initializeApp(FirebaseApp.java:252)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(FirebaseInitProvider.java:51)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2388)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2358)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(FirebaseInitProvider.java:45)
at android.app.ActivityThread.installProvider(ActivityThread.java:7239)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6780)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6697)
at android.app.ActivityThread.access$1300(ActivityThread.java:237)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1913)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7656)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
2021-03-29 00:28:45.654 31916-31979/com.example.finalyearprojectapp W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
2021-03-29 00:28:45.667 31916-31979/com.example.finalyearprojectapp I/FirebaseAuth: [FirebaseAuth:] Loading module via FirebaseOptions.
2021-03-29 00:28:45.667 31916-31979/com.example.finalyearprojectapp I/FirebaseAuth: [FirebaseAuth:] Preparing to create service connection to gms implementation
Upvotes: 0
Views: 345
Reputation: 1796
You want to create a Base class that extends the MultiDex if you don't have one.
public class BaseApp extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
}
}
Your Manifest can look like below:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.finalyearprojectapp">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".BaseApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainScreen" />
<activity android:name=".RegisterActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Edit: You should upgrade your firebase to the latest, or at least version from 17.0.0 and above. I was told that According to firebase release notes May 07, 2019, it says; "If you use Firebase Authentication, update to firebase-auth v17.0.0 or later to ensure functionality alignment with other updated Firebase libraries."
Upvotes: 1