when i call "realm.copyToRealmOrUpdate({RealmObject})", app crashes on lower API(21-25). No problem in version API-25 and above. Logcat output :
java.lang.IncompatibleClassChangeError: The method 'java.lang.Class java.lang.Object.getClass()' was expected to be of type interface but instead was found to be of type virtual (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
at io.realm.DefaultRealmModuleMediator.copyOrUpdate(DefaultRealmModuleMediator.java:131)
at io.realm.Realm.copyOrUpdate(Realm.java:1815)
at io.realm.Realm.copyToRealmOrUpdate(Realm.java:1199)
at com.viyatek.ultimatefacts.Activites.MainActivity.DataFetched$lambda-10(MainActivity.kt:826)
at com.viyatek.ultimatefacts.Activites.MainActivity.$r8$lambda$fX_wkxDWKFkFuw4LXNz0m5YzJyo(MainActivity.kt)
at com.viyatek.ultimatefacts.Activites.MainActivity$$ExternalSyntheticLambda4.execute(D8$$SyntheticClass)
at io.realm.Realm.executeTransaction(Realm.java:1604)
at com.viyatek.ultimatefacts.Activites.MainActivity.DataFetched(MainActivity.kt:823)
at com.viyatek.ultimatefacts.NetworkOperations.getData.ExecuteNetWorkCall$lambda-0(getData.kt:111)
at com.viyatek.ultimatefacts.NetworkOperations.getData.$r8$lambda$Va8-rJSbrmVyGMKSedsNwZR74V8(getData.kt)
at com.viyatek.ultimatefacts.NetworkOperations.getData$$ExternalSyntheticLambda1.onResponse(D8$$SyntheticClass)
at com.android.volley.toolbox.JsonRequest.deliverResponse(JsonRequest.java:100)
at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:102)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
i use in top-level gradle;
classpath "io.realm:realm-gradle-plugin:10.10.1"
I have no idea for the solution. I added try-catch block for now. I suspect ProGuard. but, for now i couldn't find the solution
I was running the app under Guest Login and the App is crashing at launcher screen. And the app is fine under the Normal Login
I referred this link ,link2 but no solution found.
Crash Report
java.lang.RuntimeException: Unable to start activity ComponentInfo {com.packagename.projectname/com.packagename.projectname.LancherActivity}: java.lang.IllegalArgumentException: Optimized data directory /storage/emulated/12/optimized is not owned by the current user. Shared storage cannot protect your application from code injection attacks.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.IllegalArgumentException: Optimized data directory /storage/emulated/12/optimized is not owned by the current user. Shared storage cannot protect your application from code injection attacks.
at dalvik.system.DexFile.<init>(DexFile.java:102)
at dalvik.system.DexFile.loadDex(DexFile.java:151)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:265)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:223)
at dalvik.system.DexPathList.<init>(DexPathList.java:109)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
at dalvik.system.DexClassLoader.<init>(DexClassLoader.java:57)
at DexLoader7.<clinit>(Unknown Source)
at com.packagename.projectname.LauncherActivity.ʾ$3bf1605b(:753)
at com.packagename.projectname.LauncherActivity.ʽ(:266)
at com.packagename.projectname.LauncherActivity.onCreate(:197)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
... 10
Error that caused in that line at com.packagename.projectname.LauncherActivity.ʾ$3bf1605b(:753) was using Google Plus Login.
return new GoogleApiClient.Builder(SigninActivity.this).addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(Plus.API, Plus.PlusOptions.builder().build()).addScope(Plus
.SCOPE_PLUS_LOGIN).build();
Processes are isolated per user unless otherwise specified, you cannot access another user's data partition if its not your current user.
For instance, 0 can't access 10 and vice-versa.
if (android.os.Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
ShimmerTextView mShimmerTextView = (ShimmerTextView) findViewById(R.id.shimmerMotion);
new Shimmer().start(mShimmerTextView);
}
As seen is the image there are only two layout files in the respective version folders. I am testing on API 22 device and so it should pick the layout from layout-v14 but instead it is inflating the layout-v10 file.
If I click holding control on the view then android studio opens v14 layout in studio as seen in image below.
v10 layout folder does not have that view.
Why is my device picking the v10 layout to inflate instead of v14 when my device is running on API22.
When I click on the TextView it should become a shimmer text and this was working for weeks until now. But today it is throwing NPE.
08-20 20:21:21.765 18635-18635/com.ralok.antitheftalarm E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.ralok.antitheftalarm, PID: 18635
java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.romainpiel.shimmer.ShimmerViewBase.isSetUp()' on a null object reference
at com.romainpiel.shimmer.Shimmer.start(Shimmer.java:150)
at com.ralok.view.HomePage.startMotionModeDetection(HomePage.java:650)
at com.ralok.view.HomePage.onClick(HomePage.java:450)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)`enter code here`
I have imported my eclipse project to Android studio everything is working fine. I have custom Actionbar
which is like this: Oncreate of an activity I have the following
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getActionBar().setCustomView(R.layout.bartitle);
TextView textViewTitle = (TextView) findViewById(R.id.titleEDIT);
textViewTitle.setText(res.getString(R.string.title));
setContentView(R.layout.register);
and now I have added Style for v21 too.
Style.xml for version 21 has the following:
<resources>
<style name="AppBaseTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowActionBar">true</item>
</style>
</resources>
When I run the project: I get a white Screen and force Close with the following error log:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.flm.sPar/com.flm.sPar.Register}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setCustomView(int)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setCustomView(int)' on a null object reference
at com.flm.sPar.Register.onCreate(Register.java:71)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
I have been trying to solve this issue. Trying out all solutions given on SO or Google but couldn't get to solve the issue. Hence thought of asking a question on SO.
Thanks!
Use getSupportActionBar() instead of getActionBar() because you are using AppCompat library. If you're using the v7 appcompat library, your activity should instead extend AppCompatActivity and not Activity.
ActionBarActivity is deprecated in revision 22.1.0 of the Support Library and so AppCompatActivity should be used instead of ActionBarActivity as suggested by a user in comments.
Hope this will solve your issue :)
I have set android:onclick in xml for an imageButton and put that method in my activity. In android s below 5 it works fine but in android 5 it gives me Error.
My imageButton code:
<ImageButton
android:id="#+id/photo_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/detail_icon"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:background="#drawable/image_background"
android:onClick="photoDetailButtonMethod"/>
My method code:
public void photoDetailButtonMethod(View theButton)
{
//something
}
The error:
java.lang.IllegalStateException: Could not find a method photoDetailButtonMethod(View) in the activity class android.view.ContextThemeWrapper for onClick handler on view class android.widget.ImageButton with id 'photo_detail'
at android.view.View$1.onClick(View.java:3994)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
Caused by: java.lang.NoSuchMethodException: photoDetailButtonMethod [class android.view.View]
at java.lang.Class.getMethod(Class.java:664)
at java.lang.Class.getMethod(Class.java:643)
at android.view.View$1.onClick(View.java:3987)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
By looking the error I can see it searching for my method in android.view.ContextThemeWrapper class so it endup with NoSuchMethodException.
I can't figure out how to solve this, any help?
1) I already added tools:context=".PhotoViewerActivity" in the root of my layout.
2) The activiy extends ActionBarActivity with appCompat theme.
I had a very similar problem, it happens only on Android Lollipop, whilst it works fine on the older versions. Looks like a bug or undocumented feature in 5.0.
Make sure that in the layout file where your ImageButton resides there is no android:theme set, i.e. nothing like this:
android:theme="#style/Base.Theme.AppCompat.Light"
Instead, define your application theme in AndroidManifest.xml application element:
<application
...
android:theme="#android:style/Theme.Holo.Light"
... >
i can't find what is the real problem, maybe some incompatiblity between eclipse and api 21 or something else.
for now i just set an onClickListener for that button.
finally i found the problem.
all i need is to associate the xml layout to an activity. for this in the design tab of xml layout make sure you selected the right activity.
It happens when you have declared the public void onClick(View view) method inside the fragment instead of activity
Be sure that your onClick method
public void photoDetailButtonMethod(View theButton)
{
//something
}
is written outside onCreate() method and in your Activity class.
I was doing this with a "menuItem", and had this:
public void photoDetailButtonMethod(View theButton)
{
//something
}
Which is wrong for menuItems. Then you must have this:
public void photoDetailButtonMethod(MenuItem theButton)
{
//something
}
It was throwing the same error as mentioned by the OP.
Hope this helps someone...
Its just google play services issue and nothing to do with your coding or settings blah blah...
just update your google play services of phone and add dependencies in build.gradle file like:
compile 'com.google.android.gms:play-services:7.5.0'