Hello, after ionic cordova emulate android
my apk was built successfully. Then I sent it to my Android ./adb install -r debug-app.apk
. But after that, when I click to open myApp, a message appears “The MyApp stopped”.
Example:
> ionic-app-scripts build --prod --target cordova --platform android
[16:43:47] ionic-app-scripts 3.1.9
[16:43:47] build prod started ...
[16:43:47] clean started ...
[16:43:47] clean finished in 4 ms
[16:43:47] copy started ...
[16:43:47] copy finished in 112 ms
[16:43:47] deeplinks started ...
[16:43:47] deeplinks finished in 411 ms
[16:43:47] ngc started ...
[16:44:05] ngc finished in 17.84 s
[16:44:05] preprocess started ...
[16:44:05] preprocess finished in less than 1 ms
[16:44:05] webpack started ...
[16:46:31] webpack finished in 146.12 s
[16:46:31] uglify started ...
[16:46:31] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[16:46:33] sass finished in 1.54 s
[16:46:33] cleancss started ...
[16:46:36] cleancss finished in 2.79 s
[16:47:16] uglify finished in 45.12 s
[16:47:16] postprocess started ...
[16:47:16] postprocess finished in 35 ms
[16:47:16] lint started ...
[16:47:16] build prod finished in 209.71 s
[16:47:21] lint finished in 4.44 s
> cordova build android
Android Studio project detected
Preparing Firebase on Android
ANDROID_HOME=/opt/android-studio
JAVA_HOME=/opt/jdk
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.
at build_780u3077cn02lc80rzxvnren2.run(/home/rodrigo/Projetos/MyApp/ionic/MyApp/platforms/android/app/build.gradle:144)
:CordovaLib:preBuild UP-TO-DATE
:CordovaLib:preDebugBuild UP-TO-DATE
:CordovaLib:compileDebugAidl UP-TO-DATE
:CordovaLib:compileDebugRenderscript UP-TO-DATE
:CordovaLib:checkDebugManifest UP-TO-DATE
:CordovaLib:generateDebugBuildConfig UP-TO-DATE
:CordovaLib:prepareLintJar UP-TO-DATE
:CordovaLib:generateDebugResValues UP-TO-DATE
:CordovaLib:generateDebugResources UP-TO-DATE
:CordovaLib:packageDebugResources UP-TO-DATE
:CordovaLib:platformAttrExtractor UP-TO-DATE
:CordovaLib:processDebugManifest UP-TO-DATE
:CordovaLib:processDebugResources UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:javaPreCompileDebug UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
:CordovaLib:processDebugJavaRes NO-SOURCE
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForDebug UP-TO-DATE
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:CordovaLib:packageDebugRenderscript NO-SOURCE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:prepareLintJar UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:createDebugCompatibleScreenManifests UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:splitsDiscoveryTaskDebug UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:javaPreCompileDebug UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:compileDebugSources UP-TO-DATE
:CordovaLib:mergeDebugShaders UP-TO-DATE
:CordovaLib:compileDebugShaders UP-TO-DATE
:CordovaLib:generateDebugAssets UP-TO-DATE
:CordovaLib:mergeDebugAssets UP-TO-DATE
:app:mergeDebugShaders UP-TO-DATE
:app:compileDebugShaders UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:transformClassesWithStackFramesFixerForDebug UP-TO-DATE
:app:transformClassesWithDesugarForDebug UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug UP-TO-DATE
:app:transformDexArchiveWithDexMergerForDebug UP-TO-DATE
:CordovaLib:compileDebugNdk NO-SOURCE
:CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
:CordovaLib:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:CordovaLib:transformNativeLibsWithIntermediateJniLibsForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders UP-TO-DATE
:app:transformNativeLibsWithMergeJniLibsForDebug UP-TO-DATE
:app:processDebugJavaRes NO-SOURCE
:app:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
:app:validateSigningDebug
:app:packageDebug
:app:assembleDebug
:app:cdvBuildDebug
BUILD SUCCESSFUL in 8s
46 actionable tasks: 3 executed, 43 up-to-date
Built the following apk(s):
/home/rodrigo/Projetos/MyApp/ionic/MyApp/platforms/android/app/build/outputs/apk/debug/app-debug.apk
Without a log, I ran ./adb logcat *:E
and the result was:
E/dalvikvm( 7080): >>>>> Normal User
E/dalvikvm( 7080): >>>>> myapp.com.br [ userId:0 | appId:10122 ]
E/OpenGLRenderer( 1207): SFEffectCache:clear(), mSize = 0
E/AndroidRuntime( 7080): FATAL EXCEPTION: main
E/AndroidRuntime( 7080): Process: myapp.com.br, PID: 7080
E/AndroidRuntime( 7080): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 7080): at com.google.firebase.perf.metrics.Trace.start(Unknown Source)
E/AndroidRuntime( 7080): at com.google.android.gms.internal.firebase-perf.zze.onActivityStarted(Unknown Source)
E/AndroidRuntime( 7080): at android.app.Application.dispatchActivityStarted(Application.java:219)
E/AndroidRuntime( 7080): at android.app.Activity.onStart(Activity.java:1080)
E/AndroidRuntime( 7080): at org.apache.cordova.CordovaActivity.onStart(CordovaActivity.java:297)
E/AndroidRuntime( 7080): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1178)
E/AndroidRuntime( 7080): at android.app.Activity.performStart(Activity.java:5311)
E/AndroidRuntime( 7080): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
E/AndroidRuntime( 7080): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2370)
E/AndroidRuntime( 7080): at android.app.ActivityThread.access$800(ActivityThread.java:155)
E/AndroidRuntime( 7080): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243)
E/AndroidRuntime( 7080): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 7080): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 7080): at android.app.ActivityThread.main(ActivityThread.java:5426)
E/AndroidRuntime( 7080): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 7080): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime( 7080): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
E/AndroidRuntime( 7080): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
E/AndroidRuntime( 7080): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 7080): Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process myapp.com.br. Make sure to call FirebaseApp.initializeApp(Context) first.
E/AndroidRuntime( 7080): at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@16.0.1:219)
E/AndroidRuntime( 7080): at com.google.android.gms.internal.firebase-perf.zzw.<init>(Unknown Source)
E/AndroidRuntime( 7080): at com.google.android.gms.internal.firebase-perf.zzw.<clinit>(Unknown Source)
E/AndroidRuntime( 7080): ... 19 more
E/android.os.Debug( 736): !@Dumpstate > sdumpstate -k -t -z -d -m 7080 -o /data/log/dumpstate_app_error
E/Watchdog( 736): !@Sync 20
E/SMD ( 242): DCD OFF
What’s wrong? The app runs fine on emulator, and the apk was built with no errors. I am using Android 4.4.4 (Samsung Galaxy Gran Prime 4G).
Suggestions?
$ ionic info
✔ Gathering environment info - done!
Ionic:
ionic (Ionic CLI) : 4.1.1 (/usr/local/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.1.9
Cordova:
cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 1.2.1, (and 5 other plugins)
System:
NodeJS : v8.10.0 (/usr/bin/node)
npm : 6.1.0
OS : Linux 4.15
$ ionic cordova plugin ls
> cordova plugin ls
com-badrit-base64 0.2.0 "Base64"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-firebase 1.1.2 "Google Firebase Plugin"
cordova-plugin-ionic-keyboard 2.1.2 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 1.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-network-information 2.0.1 "Network Information"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-whitelist 1.3.3 "Whitelist"
Note: when I make use firebase in Ionic, is necessary to install either npm install firebase angularfire2 --save
or ionic cordova plugin add cordova-plugin-firebase && npm install --save @ionic-native/firebase
? If I execute both commands, could have some conflict?