Firebase Cloud Messaging -> Illegal State Exception in Android - android

I am trying to make an app based on Cordova that is able to send Notifications via FireBase Cloud Messaging
Here the MainActivity.java
public class MainActivity extends CordovaActivity
{
#Override
public void onCreate(Bundle savedInstanceState)
{
Intent i=new Intent(this,NotificationService.class);
startService(i);
super.onCreate(savedInstanceState);
// Set by <content src="index.html" /> in config.xml
Helper mhelper=new Helper(this,appView);
FirebaseMessaging.getInstance().subscribeToTopic("Testing");
Log.d("Message","Subscribed To Testing");
Log.d("Token",FirebaseInstanceId.getInstance().getToken());
loadUrl(launchUrl);
}
}
However I am getting a Illegal State Exception at Line 49:
FirebaseMessaging.getInstance().subscribeToTopic("Testing");
The rest Manifest.xml etc. are the same as the sample provided here
https://github.com/firebase/quickstart-android/tree/master/messaging
In the Logcat, the error it is showing is::
FATAL EXCEPTION: main
Process: careerage.jobseeker.app, PID: 5764
java.lang.RuntimeException: Unable to start activity ComponentInfo{careerage.jobseeker.app/careerage.jobseeker.app.MainActivity}: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3738)
at android.app.ActivityThread.access$900(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
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:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
at com.google.firebase.messaging.FirebaseMessaging.getInstance(Unknown Source)
at careerage.jobseeker.app.MainActivity$override.onCreate(MainActivity.java:49)
at careerage.jobseeker.app.MainActivity$override.access$dispatch(MainActivity.java)
at careerage.jobseeker.app.MainActivity.onCreate(MainActivity.java:0)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3738) 
at android.app.ActivityThread.access$900(ActivityThread.java:135) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1202) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5017) 
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:779) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
at dalvik.system.NativeStart.main(Native Method) 
I tried java.lang.IllegalStateException: FirebaseApp with name [DEFAULT]
but still it doesn't recognize FirebaseDatabase Class

Try updating your dependency to:
compile 'com.google.firebase:firebase-messaging:9.0.2'
This bug was fixed in patches between 9.0.0 and 9.0.2

I think Fcm and Gcm take some time to get tokens.. If you try to do anything with cloud messaging without the token being assigned you will get error.

Related

Greendao and NoClassDefFoundError

In the process of using greendao, when the initialization time, being given:
java.lang.NoClassDefFoundError: org.greenrobot.greendao.query.WhereCollector
This exception did not occur during the compilation process, and the actual error code crashed directly at run time as follows:
AndroidRuntime: FATAL EXCEPTION: main
Process: com.luckytry.hybrid.mainapplication, PID: 4274
java.lang.NoClassDefFoundError: org.greenrobot.greendao.query.WhereCollector
at org.greenrobot.greendao.query.QueryBuilder.<init>(QueryBuilder.java:85)
at org.greenrobot.greendao.query.QueryBuilder.<init>(QueryBuilder.java:77)
at org.greenrobot.greendao.query.QueryBuilder.internalCreate(QueryBuilder.java:73)
at org.greenrobot.greendao.AbstractDao.queryBuilder(AbstractDao.java:793)
at com.luckytry.luckylibrary.MyAplication.APPAplication.initData(APPAplication.java:132)
at com.luckytry.luckylibrary.MyAplication.APPAplication.initDB(APPAplication.java:117)
at com.luckytry.luckylibrary.MyAplication.APPAplication.onCreate(APPAplication.java:39)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1009)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4655)
at android.app.ActivityThread.access$1800(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5356)
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:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)
at dalvik.system.NativeStart.main(Native Method)
Try this:
-Add this dependency compile 'com.android.support:multidex:1.0.1'
-Add multiDexEnabled = true in your build.gradle app config.
-Change your extend Application "MyAplication.APPAplication" to MultiDexApplication.

Package Manager has died, DeadObjectException

We use our app on only one device type and we get this error pretty often on it.
The only instance for PackageManager is a BootupReceiver:
public class RestartHelper extends BroadcastReceiver
{
#Override
public void onReceive(Context context, Intent intent) {
Logger.getInstance().Log("Restart received");
Intent i = context.getPackageManager().getLaunchIntentForPackage( context.getPackageName() );
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(i);
}
}
Exception:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test/com.test.MainActivity}: java.lang.RuntimeException: Package manager has died
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2390)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5292)
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:824)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: Package manager has died
at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:239)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:301)
at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:281)
at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:152)
at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:60)
at com.cotris.roosapp.StandardActivity.onCreate(StandardActivity.java:49)
at com.cotris.roosapp.MainActivity.onCreate(MainActivity.java:64)
at android.app.Activity.performCreate(Activity.java:5264)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)
... 11 more
Caused by: android.os.DeadObjectException
at android.os.BinderProxy.transact(Native Method)
at android.content.pm.IPackageManager$Stub$Proxy.getActivityInfo(IPackageManager.java:1791)
at android.app.ApplicationPackageManager.getActivityInfo(ApplicationPackageManager.java:234)
... 20 more
Is this error hardware/system related?
Obviously there has another PackageManger call but not only in RestartHelper.java:
at com.cotris.roosapp.StandardActivity.onCreate(StandardActivity.java:49)
You man need to check the code detail in that.
The android.os.DeadObjectException means that you link to something, that does not exist any more.
the solution for my case was a hardware related problem, which created all kind of crashes of system processes in the background on the device.

Cocos2d-x v3.7.1 Unfortunately, libcocos2dx has stopped

I'm compiling a new project through proj.android-studio using:
cocos compile -p android --android-studio
But when I start app on android device, it shows me a message:
Unfortunately, libcocos2dx has stopped
Can you help me? What I'm doing wrong?
Here is logcat:
09-07 12:07:47.711 23074-23074/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: org.cocos2dx.TestGame, PID: 23074
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "srand" referenced by "libcocos2dcpp.so"...
at java.lang.Runtime.loadLibrary(Runtime.java:371)
at java.lang.System.loadLibrary(System.java:553)
at org.cocos2dx.lib.Cocos2dxActivity.onLoadNativeLibraries(Cocos2dxActivity.java:288)
at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:303)
at android.app.Activity.performCreate(Activity.java:5343)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1088)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2331)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5341)
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:825)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:641)
at dalvik.system.NativeStart.main(Native Method)
Usually the app stops working if your code contains errors.
Are there errors in your code? What does the LogCat say?

Error on SIMPLE ANDROID OCR

When I tried the Simple Android OCR (https://github.com/GautamGupta/Simple-Android-OCR) in ANDROID STUDIO it gave me a runtime error as shown in the picture. Can anyone help me with this?
![Runtime error occured when tried to run][2]
06-03 12:44:31.904 17051-17051/com.startup.vrvijay.liccamera E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.startup.vrvijay.liccamera, PID: 17051
android.util.SuperNotCalledException: Activity {com.startup.vrvijay.liccamera/com.startup.vrvijay.liccamera.MainActivity} did not call through to super.onCreate()
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2333)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2429)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1342)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5333)
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:828)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(Native Method)
You forgot to place:
super.onCreate(savedInstanceState);
right after your
protected void onCreate(Bundle savedInstanceState) {

Getting uknown error when using mupdf

I've tried to import mupdf to my app, but when I open it, i got some weird error and it force closes. Why? I really don't understand.
this is my logcat:
10-10 15:34:17.802 8657-8657/com.tproductions.Openit E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.tproductions.Openit, PID: 8657
java.lang.UnsatisfiedLinkError: Native method not found: com.artifex.mupdfdemo.MuPDFCore.openFile:(Ljava/lang/String;)J
at com.artifex.mupdfdemo.MuPDFCore.openFile(Native Method)
at com.artifex.mupdfdemo.MuPDFCore.<init>(MuPDFCore.java:68)
at com.artifex.mupdfdemo.MuPDFActivity.openFile(MuPDFActivity.java:204)
at com.artifex.mupdfdemo.MuPDFActivity.onCreate(MuPDFActivity.java:303)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:212)
at android.app.ActivityThread.main(ActivityThread.java:5135)
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:877)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
at dalvik.system.NativeStart.main(Native Method)
It looks like something has gone wrong in the native build.
It's probably best to retry that; there are instructions here:
http://www.mupdf.com/doc/how-to-build-mupdf-for-android
and here:
http://git.ghostscript.com/?p=mupdf.git;a=blob_plain;f=platform/android/ReadMe.txt;hb=HEAD
It's probably best to use the git code from master - the latest is 1.6, versions prior to 1.5 are unlikely to build cleanly with the current NDKs.

Categories

Resources