I'm implementing the huawei ads in the android Application. I have go through all the https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/publisher-service-banner-0000001050066915 and successfully implemented the ads but android studio preview is giving me error and is not displaying the preview when adding the huawei ads in the xml. After Removing the Huawei Ads preview is showing.
Following is the my layout:
<?xml version="1.0" encoding="utf-8"?>
<com.huawei.hms.ads.nativead.NativeView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/native_video_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="#FFFFFF"
android:orientation="vertical">
<com.huawei.hms.ads.nativead.MediaView
android:id="#+id/ad_media"
android:layout_width="match_parent"
android:layout_height="#dimen/_200sdp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_50sdp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:background="#color/white">
<TextView
android:id="#+id/ad_title"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:alpha="1"
android:textColor="#000000"
android:textSize="#dimen/hiad_text_13_sp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"/>
<TextView
android:id="#+id/ad_source"
android:layout_width="wrap_content"
android:layout_height="19dp"
android:layout_marginStart="24dp"
android:layout_marginTop="2dp"
android:layout_marginBottom="16dp"
android:alpha="0.6"
android:text="asdfasj"
android:maxWidth="158dp"
android:textColor="#666666"
android:textSize="#dimen/hiad_text_12_sp"
app:layout_constraintStart_toStartOf="#id/ad_title"
app:layout_constraintEnd_toStartOf="#id/ad_flag"
app:layout_constraintTop_toBottomOf="#id/ad_title"
/>
<TextView
android:id="#+id/ad_flag"
android:layout_width="20dp"
android:layout_height="14dp"
android:background="#drawable/native_flag_rounded_corners_shape"
android:text="#string/ad_flag"
android:textColor="#FFFFFF"
android:textSize="8sp"
android:layout_marginStart="#dimen/_10sdp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="#id/ad_source"
app:layout_constraintStart_toEndOf="#id/ad_source"
app:layout_constraintTop_toTopOf="#id/ad_source" />
<Button
android:id="#+id/ad_call_to_action"
android:layout_width="72dp"
android:layout_height="26dp"
android:layout_alignParentEnd="true"
android:background="#drawable/native_button_rounded_corners_shape"
android:textColor="#FFFFFF"
android:textSize="10sp"
android:layout_marginEnd="#dimen/_20sdp"
app:layout_constraintBottom_toBottomOf="#+id/ad_source"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.huawei.hms.ads.nativead.NativeView>
Following is the error I m encountering with
When I remove the root tag to Constraint Layout. Preview is visible on Screen and all errors are gone. Inside those two tags I m facing the following Exception:
FirstException: Don't Create Threads in Preview
java.lang.IllegalStateException: It is not allowed to create new
threads in the preview at com.huawei.hms.ads.kn.newThread at
java.util.concurrent.ThreadPoolExecutor$Worker.(ThreadPoolExecutor.java:623)
at
java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:912)
at
java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1343)
at com.huawei.hms.ads.km.Code at com.huawei.hms.ads.km.I at
com.huawei.hms.ads.lj.Code at com.huawei.hms.ads.lj.V at
com.huawei.hms.ads.dl.Z at com.huawei.hms.ads.dl.V at
com.huawei.hms.ads.dl.Code at
com.huawei.openalliance.ad.views.PPSNativeView.Code at
com.huawei.openalliance.ad.views.PPSNativeView. at
com.huawei.hms.ads.nativead.NativeView. at
jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(NativeConstructorAccessorImpl.java:-2)
at
jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
at android.view.LayoutInflater.inflate(LayoutInflater.java:657) at
android.view.LayoutInflater.inflate(LayoutInflater.java:499)
Second Exception: Failed to instantiate One Or more Class The
following classes could not be instantiated:
- com.huawei.hms.ads.nativead.MediaView (Open Class, Show Exception, Clear Cache)
- com.huawei.openalliance.ad.views.VideoView (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode() in your custom
views to skip code or show sample data when shown in the IDE. If this
is an unexpected error you can also try to build the project, then
manually refresh the layout. Exception Details
java.lang.NullPointerException at
com.huawei.openalliance.ad.views.NativeVideoView.Code at
com.huawei.openalliance.ad.views.NativeVideoView. at
com.huawei.hms.ads.nativead.MediaView.Code at
com.huawei.hms.ads.nativead.MediaView. at
jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(NativeConstructorAccessorImpl.java:-2)
at
jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at
jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
at
android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:1121)
at
android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1095)
at
android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
at android.view.LayoutInflater.inflate(LayoutInflater.java:680) at
android.view.LayoutInflater.inflate(LayoutInflater.java:499)
I have invalidate the Cache and restart the Android Studio but nothing has worked yet. Can any one help me to render the preview. Any help would be appreciated. Thanks
Currently, the Ads kit SDK references the HMS base SDK code, but seems you have not integrate the HMS base SDK.
As a result, this following error occurs during preview.
If you choose not to integrate the HMS base SDK, the Ads SDK function is not affected but will be affected during preview.
So there are two options for your reference :
One way is you can try to integrate the hms base sdk, or another way is to ignore this preview error, because this will not affect the actual operation.
Related
I thought I should add a toolbar as I'll need a settings button.
So I added this to my main_activity.xml
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="PSA MFD"
app:subtitle="Multi functional display for Citroen and Peugeot"
app:logo="#android:drawable/ic_menu_call"
app:navigationIcon="#drawable/ic_fan"
/>
But now my app won't run because:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.rwb.psamfd/com.rwb.psamfd.MainActivity}: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class android.support.v7.widget.Toolbar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class android.support.v7.widget.Toolbar
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class android.support.v7.widget.Toolbar
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v7.widget.Toolbar" on path: DexPathList[[zip file "/data/app/com.rwb.psamfd-2/base.apk"],nativeLibraryDirectories=[/data/app/com.rwb.psamfd-2/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:609)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.rwb.psamfd.MainActivity.onCreate(MainActivity.kt:31)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
What do I ned to do? I have absolutely no idea. (I'm new to Android development -- and it's very difficult compared to C#).
Method 1:
Add the following to your dependencies in build.gradle file:
dependencies {
...
**implementation 'androidx.appcompat:appcompat:1.0.0'**
}
And change your toolbar as:
<androidx.appcompat.widget.Toolbar
....
Your contents
....>
<androidx.appcompat.widget.Toolbar/>
Method 2:
You can migrate to androidx directly.
Hope you will find the solution.
I'm trying to insert a chip into my project but I got the message: Fail to instantiate one or more classes. Look below to more details.
<com.robertlevonyan.views.chip.Chip
android:id="#+id/chip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Basic test" />
I've tried with two versions, 1.2.4 and 2.0.3 (latest), but neither worked. I got this message on my Issues Message:
Failed to instantiate one or more classes.
This did not allow me to insert a chip into my project.
What did I try?
I tried cleaning the cache, installing another version, and restarting Android Studio IDE but they did not work.
I tried with robertlevonyan/materialChipView and Materialize Chip
Exception
java.lang.NoClassDefFoundError: com/robertlevonyan/views/chip/R$styleable at com.robertlevonyan.views.chip.Chip.initTypedArray(Chip.kt:113) at com.robertlevonyan.views.chip.Chip.<init>(Chip.kt:104) at com.robertlevonyan.views.chip.Chip.<init>(Chip.kt:102) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:403) at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:186) at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:144) at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:309) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:418) at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:429) at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:333) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730) at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863) at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72) at android.view.LayoutInflater.rInflate(LayoutInflater.java:837) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824) at android.view.LayoutInflater.inflate(LayoutInflater.java:515) at android.view.LayoutInflater.inflate(LayoutInflater.java:394) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:323) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:394) at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:200) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:572) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$5(RenderTask.java:698) at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
Thanks.
Edit: I tried to create my own drawable chip but I need to change the color dynamically so I really need to use this 3rd libs.
It took a lot of effort to migrate to androidX, but after all that I am still unable to resolve one issue.
When I try to run my app I get this error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{studio.dookola.zgkim/studio.dookola.zgkim.MainActivity}: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.CoordinatorLayout" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/base.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_dependencies_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_resources_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_0_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_1_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_2_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_3_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_4_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_5_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_6_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_7_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_8_apk.apk", zip file "/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:965)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:859)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
2019-07-21 22:15:47.519 18965-18965/studio.dookola.zgkim E/AndroidRuntime: at studio.dookola.zgkim.MainActivity.onCreate(MainActivity.java:72)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/studio.dookola.zgkim-dWUlCZ9saQuQRJ7D8y0mqQ==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:354)
at dalvik.system.DexFile.<init>(DexFile.java:101)
at dalvik.system.DexFile.<init>(DexFile.java:75)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
at android.app.LoadedApk.getResources(LoadedApk.java:1032)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
... 6 more
The pointed line 72 of MainActivity: setContentView(R.layout.activity_main);
My MainActivity .xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer"
/>
</androidx.drawerlayout.widget.DrawerLayout>
I have no idea what causes the problem.
I've searched stack overflow, but found no solution.
Any suggestion would be appreciated.
Caused by: android.view.InflateException: Binary XML file line #12: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
From these, I would guess that you haven't changed your dependencies and XML tags when migrating to AndroidX. The Refactor > Migrate to AndroidX tool doesn't do that for you, unfortunately, it only changes Java references. See this for more information. When you are done changing the Gradle dependencies, please change all older Android support tags to newer AndroidX tags in your XML files.
Layout Preview issue for Android Studio 2.3
I do not know what the problem is.
Is there a solution to this?
=== configuration start ===
os: mac 10.12.3
ide: version: 2.3
compileSdkVersion: 25
buildToolsVersion: 25.0.2
supportLibraryVersion: 25.3.0
=== configuration end ===
=== error report start ===
17356
java.lang.ArrayIndexOutOfBoundsException: 17356
at org.jetbrains.org.objectweb.asm.ClassReader.readUnsignedShort(ClassReader.java:2322)
at org.jetbrains.org.objectweb.asm.ClassReader.getAttributes(ClassReader.java:2200)
at org.jetbrains.org.objectweb.asm.ClassReader.accept(ClassReader.java:565)
at org.jetbrains.org.objectweb.asm.ClassReader.accept(ClassReader.java:506)
at com.android.tools.idea.rendering.ClassConverter.rewriteClass(ClassConverter.java:184)
at com.android.tools.idea.rendering.ClassConverter.rewriteClass(ClassConverter.java:77)
at com.android.tools.idea.rendering.RenderClassLoader.convertClass(RenderClassLoader.java:164)
at com.android.tools.idea.rendering.RenderClassLoader.loadClass(RenderClassLoader.java:148)
at com.android.tools.idea.rendering.RenderClassLoader.loadClassFile(RenderClassLoader.java:129)
at org.jetbrains.android.uipreview.ModuleClassLoader.loadClassFile(ModuleClassLoader.java:380)
at org.jetbrains.android.uipreview.ModuleClassLoader.loadClassFromModule(ModuleClassLoader.java:280)
at org.jetbrains.android.uipreview.ModuleClassLoader.loadClassFromModuleOrDependency(ModuleClassLoader.java:239)
at org.jetbrains.android.uipreview.ModuleClassLoader.load(ModuleClassLoader.java:176)
at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:56)
at org.jetbrains.android.uipreview.ModuleClassLoader.findClass(ModuleClassLoader.java:127)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.jetbrains.android.uipreview.ModuleClassLoader.loadClass(ModuleClassLoader.java:222)
at java.lang.Class.getDeclaredClasses0(Native Method)
at java.lang.Class.getDeclaredClasses(Class.java:1867)
at org.jetbrains.android.uipreview.ViewLoader.parseClass(ViewLoader.java:137)
at org.jetbrains.android.uipreview.ViewLoader.loadAndParseRClass(ViewLoader.java:647)
at org.jetbrains.android.uipreview.ViewLoader.loadAndParseRClassSilently(ViewLoader.java:581)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadAndParseRClass(LayoutlibCallbackImpl.java:682)
at com.android.tools.idea.rendering.RenderTask.<init>(RenderTask.java:178)
at com.android.tools.idea.rendering.RenderService.createTask(RenderService.java:241)
at com.android.tools.idea.uibuilder.model.NlModel.inflate(NlModel.java:362)
at com.android.tools.idea.uibuilder.model.NlModel.render(NlModel.java:554)
at com.android.tools.idea.uibuilder.model.NlModel$3.run(NlModel.java:599)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue.lambda$flush$1(MergingUpdateQueue.java:260)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:274)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:229)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:222)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:378)
at com.intellij.util.Alarm$Request.run(Alarm.java:389)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:227)
at com.intellij.util.concurrency.BoundedTaskExecutor.runFirstTaskThenPollAndRunRest(BoundedTaskExecutor.java:178)
at com.intellij.util.concurrency.BoundedTaskExecutor.access$000(BoundedTaskExecutor.java:40)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:197)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
=== Layout XML ===
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent”>
<android.support.design.widget.AppBarLayout>
<android.support.v7.widget.Toolbar />
<android.support.design.widget.TabLayout />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager />
</RelativeLayout>
It happened to me after Android Studio update and to the layout files where i was using custom components.
In Android Studio, select File > Invalidate Caches and Restart
EditText's hint or text attributes string length should not be more than 18 chars. If u can't avoid this then use #string/mylongtext
I'm getting this wierd error. When I came back to work yesterday night, I was facing this error. What I didn't understand is that I never changed anything in the code. It feels like it came out of the blue.
07-21 01:23:52.051 27020-27020/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.thinkinetics.rob.routinebuilder, PID: 27020
java.lang.RuntimeException: Unable to instantiate service com.thinkinetics.rob.RoutineWatchface: java.lang.ClassNotFoundException: Didn't find class "com.thinkinetics.rob.RoutineWatchface" on path: DexPathList[[zip file "/data/app/com.thinkinetics.rob.routinebuilder-2/base.apk"],nativeLibraryDirectories=[/data/app/com.thinkinetics.rob.routinebuilder-2/lib/arm, /vendor/lib, /system/lib]]
at android.app.ActivityThread.handleCreateService(ActivityThread.java:2862)
at android.app.ActivityThread.-wrap4(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.thinkinetics.rob.RoutineWatchface" on path: DexPathList[[zip file "/data/app/com.thinkinetics.rob.routinebuilder-2/base.apk"],nativeLibraryDirectories=[/data/app/com.thinkinetics.rob.routinebuilder-2/lib/arm, /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 android.app.ActivityThread.handleCreateService(ActivityThread.java:2859)
at android.app.ActivityThread.-wrap4(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5422)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Suppressed: java.lang.ClassNotFoundException: Didn't find class "com.thinkinetics.rob.RoutineWatchface" on path: DexPathList[[dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-support-annotations-23.0.0_46201fc775bd6a2a1b3e71eae86ef67f12babd28-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_9-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_8-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_7-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_6-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_5-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_4-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_3-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_2-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_1-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-slice_0-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-internal_impl-23.0.0_93b2086be48ba8bf011786c70052b2e5db3ad593-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-com.google.android.support-wearable-1.3.0_c1d538a0bc8f53c23014746aa746d7950ae7bc3a-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-com.google.android.gms-play-services-wearable-8.4.0_921a6b02116cb3c5229600c4895d4c7fb55e5cef-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-com.google.android.gms-play-services-basement-8.4.0_3194cc3fb6ccb6c92a69d7fc4ace71b161b64889-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-com.google.android.gms-play-services-base-8.4.0_30a8813ef567e92576c485da70ce277d4fc2397e-classes.dex", dex file "/data/data/com.thinkinetics.rob.routinebuilder/files/instant-run/dex/slice-com.android.support-support-v4-23.0.0_7bc710f5526f9681c52eb6e494ababfb
Note: I did search for other questions with the same issue and I did find some. However, I followed every advice on those posts and it did not help me. After wasting my whole night I thought it would be a good idea to post here.
I'm not sure which parts of my code, if any, I should post along with this so I'll look at this actively and edit if necessary.
Here is the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thinkinetics.rob">
<uses-feature android:name="android.hardware.type.watch" />
<!-- Required to act as a custom watch face. -->
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#android:style/Theme.DeviceDefault">
<service
android:name=".RoutineWatchface"
android:label="#string/my_digital_name"
android:permission="android.permission.BIND_WALLPAPER">
<meta-data
android:name="android.service.wallpaper"
android:resource="#xml/watch_face" />
<meta-data
android:name="com.google.android.wearable.watchface.preview"
android:resource="#drawable/preview_digital" />
<meta-data
android:name="com.google.android.wearable.watchface.preview_circular"
android:resource="#drawable/preview_digital_circular" />
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
</service>
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
</application>
</manifest>
Thank you.
I encountered the same issue just now. I uninstalled the app from device, rebuilt the project and then installed again. This time I did not face the problem, and it worked fine.
It might be some intermittent bug with instant-run feature in studio.