getting exception when try to use vector Drawables in Android Studio - android

My Code is Working Fine but whenever I try to add the vectordrables in my app I got the exception.
I am Using RecyclerView to Show the item list.
https://i.imgur.com/GRuWMe5.png
My xml item layout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="wrap_content">
<TextView
android:layout_margin="8dp"
android:id="#+id/note_text"
android:layout_width="0dp"
android:textColor="#333"
android:layout_height="wrap_content"
android:text="Sample Text"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/fab_edit_note"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab_edit_note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:src="#drawable/ic_edit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
if I run the app with vector drawables I got an exception and when remove the it from FloatingActionButton.
My App works fine... I need Solution Help me to figure out...
I Also Added the Following Line in the App Module File but it didn't work...
vectorDrawables.useSupportLibrary = true
Here is Android Studio LogCat.
06-10 12:44:45.920 3137-3137/? I/art: Late-enabling -Xcheck:jni
06-10 12:44:46.150 3137-3137/com.codemsi.notes W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
06-10 12:44:46.170 3137-3137/com.codemsi.notes E/Process: android_os_Process_getProcessNameByPid pid is 3137
06-10 12:44:46.170 3137-3137/com.codemsi.notes E/Process: android_os_Process_getProcessNameByPid value is m.codemsi.notes
06-10 12:44:46.190 3137-3137/com.codemsi.notes I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>
06-10 12:44:46.190 3137-3137/com.codemsi.notes I/art: Rejecting re-init on previously-failed class java.lang.Class<androidx.core.view.ViewCompat$2>
06-10 12:44:46.460 3137-3164/com.codemsi.notes D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
06-10 12:44:46.470 3137-3137/com.codemsi.notes D/Atlas: Validating map...
06-10 12:44:46.530 3137-3164/com.codemsi.notes I/Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LA.BR.1.1.3.C8.05.01.00.115.128_msm8916_64_refs/tags/AU_LINUX_ANDROID_LA.BR.1.1.3.C8.05.01.00.115.128__release_AU (I55c48cad9a)
OpenGL ES Shader Compiler Version: E031.25.03.04
Build Date: 03/21/17 Tue
Local Branch:
Remote Branch: refs/tags/AU_LINUX_ANDROID_LA.BR.1.1.3.C8.05.01.00.115.128
Local Patches: NONE
Reconstruct Branch: NOTHING
06-10 12:44:46.540 3137-3164/com.codemsi.notes I/OpenGLRenderer: Initialized EGL, version 1.4
06-10 12:44:46.550 3137-3164/com.codemsi.notes D/OpenGLRenderer: Enabling debug mode 0
06-10 12:44:46.570 3137-3137/com.codemsi.notes W/ResourceType: Failure getting entry for 0x7f070072 (t=6 e=114) (error -75)
06-10 12:44:46.580 3137-3137/com.codemsi.notes D/AndroidRuntime: Shutting down VM
06-10 12:44:46.590 3137-3137/com.codemsi.notes E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.codemsi.notes, PID: 3137
android.view.InflateException: Binary XML file line #20: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at com.codemsi.notes.model.NotesAdapter.onCreateViewHolder(NotesAdapter.java:31)
at com.codemsi.notes.model.NotesAdapter.onCreateViewHolder(NotesAdapter.java:17)
at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7078)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6235)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404)
at android.view.View.layout(View.java:15697)
at android.view.ViewGroup.layout(ViewGroup.java:5064)
at androidx.constraintlayout.widget.ConstraintLayout.onLayout(ConstraintLayout.java:1915)
at android.view.View.layout(View.java:15697)
at android.view.ViewGroup.layout(ViewGroup.java:5064)
at com.google.android.material.appbar.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:148)
at com.google.android.material.appbar.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:43)
at com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1892)
at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:918)
at android.view.View.layout(View.java:15697)
at android.view.ViewGroup.layout(ViewGroup.java:5064)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15697)
at android.view.ViewGroup.layout(ViewGroup.java:5064)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15697)
at android.view.ViewGroup.layout(ViewGroup.java:5064)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15697)
at android.view.ViewGroup.layout(ViewGroup.java:5064)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
at android.view.View.layout(View.java:15697)
at android.view.ViewGroup.layout(ViewGroup.java:5064)
at android.widget.FrameLayout.layoutChildren(FrameLayout.java:579)
at android.widget.FrameLayout.onLayout(FrameLayout.java:514)
at android.view.View.layout(View.java:15697)
at android.view.ViewGroup.layout(ViewGroup.java:5064)
at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2260)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2010)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1189)
at android.view.ViewRootImpl$
06-10 12:44:46.680 3137-3137/com.codemsi.notes I/Process: Sending signal. PID: 3137 SIG: 9
06-10 12:44:46.680 3137-3137/com.codemsi.notes V/Process: killProcess [3137] Callers=com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException:99 java.lang.ThreadGroup.uncaughtException:693 java.lang.ThreadGroup.uncaughtException:690 <bottom of call stack>

Use app:src="#drawable/ic_edit" instead and check it out if it works

Use app:srcCompat = "#drawable/ic_edit" instead of android:src

Use app:srcCompat to reference vector drawable
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fab_edit_note"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:srcCompat="#drawable/ic_edit"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Related

update for using vectorDrawables with androidx

The solution given in this documentation page doesn't seem to be valid for androidx users(I think this because there is mention of android.support.v7.appcompat which isn't used by androidx users, right?). I might have gotten something wrong, but adding the: vectorDrawables.useSupportLibrary = true also the
static{
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
with the xml's app:srcCopmat:
<ImageButton
android:id="#+id/imageButton4"
android:layout_width="26dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageButton5"
app:layout_constraintEnd_toStartOf="#+id/imageButton5"
app:layout_constraintTop_toTopOf="#+id/imageButton5"
app:srcCompat="#drawable/sync" />
doesn't help. It simply crashes the app. The logcat reads:
file: /sys/class/power_supply/battery/hw_switch_point open error
E/dalvikvm(11099): Could not find class 'com.crashlytics.android.ndk.CrashlyticsNdk', referenced from method com.crashlytics.android.CrashlyticsInitProvider.ˊ
E/dalvikvm(11099): Could not find class 'dalvik.system.InMemoryDexClassLoader', referenced from method com.facebook.ads.internal.dynamicloading.DynamicLoaderFactory.createInMemoryClassLoader
E/dalvikvm(11099): Could not find class 'com.facebook.ads.internal.dynamicloading.DynamicLoaderImpl', referenced from method com.facebook.ads.internal.dynamicloading.DynamicLoaderFactory.doMakeLoader
E/dalvikvm(11099): Could not find class 'androidx.work.impl.background.systemjob.SystemJobService', referenced from method androidx.appcompat.view.ʖ.createBestAvailableBackgroundScheduler
E/dalvikvm(11099): Could not find class 'androidx.appcompat.view.ΐ$ˊ', referenced from method androidx.appcompat.view.ΐ.<init>
E/dalvikvm(11099): Could not find class 'android.graphics.BlendModeColorFilter', referenced from method androidx.appcompat.view.y40$if.ˊ
E/dalvikvm(11099): Could not find class 'android.graphics.BlendModeColorFilter', referenced from method androidx.appcompat.view.y40$if.ˋ
E/dalvikvm(11099): Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method androidx.appcompat.view.t40.ˊ
E/dalvikvm(11099): Could not find class 'dalvik.system.DelegateLastClassLoader', referenced from method x.a
E/dalvikvm(11099): Could not find class 'dalvik.system.DelegateLastClassLoader', referenced from method nj.a
E/dalvikvm(11099): Could not find class 'com.evozi.network.service.QSTileService', referenced from method androidx.appcompat.view.ᚁ.ˋ
E/dalvikvm(11099): Could not find class 'com.evozi.network.service.QSTileService', referenced from method androidx.appcompat.view.ᚁ.ˋ
E/dalvikvm(11099): Could not find class 'com.evozi.network.service.QSTileService', referenced from method androidx.appcompat.view.ᚁ.ᐝ
E/dalvikvm(11099): Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method com.facebook.ads.redexgen.X.OY.A09
E/dalvikvm(11099): Could not find class 'android.app.ActivityManager$AppTask', referenced from method com.facebook.ads.redexgen.X.NN.A02
E/FBAudienceNetwork(11099): You are using custom Application class and don't call AudienceNetworkAds.isInAdsProcess(). Multi-process support will be disabled. Please call AudienceNetworkAds.isInAdsProcess() if you want to support multi-process mode.
E/memtrack(11189): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug(11189): failed to load memtrack module: -2
E/PackageManager( 617): parse pkg : /data/app/vmdl-410864310.tmp
E/PackageManager( 617): dexopt start
E/Finsky (10651): [1] aabj.b(2): Package name null is not an installed package
E/PackageManager( 617): dexopt end
E/SamsungIME( 907): mOCRHelper is null
E/SamsungIME( 907): mOCRHelper is null
E/memtrack(11247): Couldn't load memtrack module (No such file or directory)
E/android.os.Debug(11247): failed to load memtrack module: -2
E/jdwp (11287): Failed sending reply to debugger: Broken pipe
E/dalvikvm(11287): Could not find class 'androidx.core.view.ViewCompat$2', referenced from method androidx.core.view.ViewCompat.addOnUnhandledKeyEventListener
E/dalvikvm(11287): Could not find class 'android.view.WindowInsets', referenced from method androidx.core.view.ViewCompat.dispatchApplyWindowInsets
E/dalvikvm(11287): Could not find class 'android.view.WindowInsets', referenced from method androidx.core.view.ViewCompat.onApplyWindowInsets
E/dalvikvm(11287): Could not find class 'android.view.View$OnUnhandledKeyEventListener', referenced from method androidx.core.view.ViewCompat.removeOnUnhandledKeyEventListener
E/dalvikvm(11287): Could not find class 'androidx.core.view.ViewCompat$1', referenced from method androidx.core.view.ViewCompat.setOnApplyWindowInsetsListener
E/AndroidRuntime(11287): FATAL EXCEPTION: main
E/AndroidRuntime(11287): Process: com.makeit.www, PID: 11287
E/AndroidRuntime(11287): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.makeit.www/com.makeit.www.StartupSetup.LogoAnimation}: android.view.InflateException: Binary XML file line #13: Error inflating class ImageView
E/AndroidRuntime(11287): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
E/AndroidRuntime(11287): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2378)
E/AndroidRuntime(11287): at android.app.ActivityThread.access$800(ActivityThread.java:155)
E/AndroidRuntime(11287): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1244)
E/AndroidRuntime(11287): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(11287): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(11287): at android.app.ActivityThread.main(ActivityThread.java:5433)
E/AndroidRuntime(11287): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(11287): at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(11287): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
E/AndroidRuntime(11287): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
E/AndroidRuntime(11287): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(11287): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class ImageView
E/AndroidRuntime(11287): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:720)
E/AndroidRuntime(11287): at android.view.LayoutInflater.rInflate(LayoutInflater.java:762)
E/AndroidRuntime(11287): at android.view.LayoutInflater.inflate(LayoutInflater.java:499)
E/AndroidRuntime(11287): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
E/AndroidRuntime(11287): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
E/AndroidRuntime(11287): at com.makeit.www.StartupSetup.LogoAnimation.onCreate(LogoAnimation.java:22)
E/AndroidRuntime(11287): at android.app.Activity.performCreate(Activity.java:5301)
E/AndroidRuntime(11287): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
E/AndroidRuntime(11287): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2291)
E/AndroidRuntime(11287): ... 11 more
E/AndroidRuntime(11287): Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_launcher_background.xml from drawable resource ID #0x7f060064
E/AndroidRuntime(11287): at android.content.res.Resources.loadDrawable(Resources.java:3451)
E/AndroidRuntime(11287): at android.content.res.TypedArray.getDrawable(TypedArray.java:614)
E/AndroidRuntime(11287): at android.widget.ImageView.<init>(ImageView.java:134)
E/AndroidRuntime(11287): at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:72)
E/AndroidRuntime(11287): at androidx.appcompat.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:187)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:107)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1407)
E/AndroidRuntime(11287): at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1457)
E/AndroidRuntime(11287): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
E/AndroidRuntime(11287): ... 21 more
E/AndroidRuntime(11287): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag vector
E/AndroidRuntime(11287): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:969)
E/AndroidRuntime(11287): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:913)
E/AndroidRuntime(11287): at android.content.res.Resources.loadDrawable(Resources.java:3447)
E/AndroidRuntime(11287): ... 30 more
E/android.os.Debug( 617): !#Dumpstate > sdumpstate -k -t -z -d -m 11287 -o /data/log/dumpstate_app_error
E/dalvikvm(11371): Could not find class 'android.app.job.JobScheduler', referenced from method com.sec.android.app.samsungapps.SamsungApps.b
E/dalvikvm(11371): Could not find class 'android.app.NotificationChannel', referenced from method com.sec.android.app.samsungapps.vlibrary.concreteloader.Common.getGeneralNotificationChannel
E/dalvikvm(11371): Could not find class 'android.app.NotificationChannel', referenced from method com.sec.android.app.samsungapps.vlibrary.concreteloader.Common.getPromotionNotificationChannel
E/dalvikvm(11371): Could not find class 'android.app.NotificationChannel', referenced from method com.sec.android.app.samsungapps.vlibrary.concreteloader.Common.getRewardsNotificationChannel
E/dalvikvm(11371): Could not find class 'android.app.NotificationChannel', referenced from method com.sec.android.app.samsungapps.vlibrary.concreteloader.Common.getUpdateNotificationChannel
E/Watchdog( 617): !#Sync 380
E/ActivityThread(11371): Failed to find provider info for null
E/ActivityThread(11371): Failed to find provider info for com.sec.android.app.clockpackage.celebvoice
E/[SAUI] (11371): Firebase initialize is success
E/SPPClientService(11407): ShipBuild Binary : True
E/SPPClientService(11407): [PackageInfoChangeReceiver] android.intent.action.PACKAGE_REMOVED
E/SPPClientService(11407): [PackageInfoChangeReceiver] [handlePkgRemovedEvent] PackageName : com.makeit.www, true, false
E/SPPClientService(11407): [PackageInfoChangeReceiver] [handlePkgRemovedEvent] Ignore Replacing case
So a little run down on how to use the vectorDrawables(or simply vector images) for androidx users for versions under Lollipop would be a huge help.
EDIT: XML layout file is:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Main.MainScreenActivity">
<LinearLayout
android:id="#+id/Toolbar_holder"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
>
<androidx.appcompat.widget.Toolbar
android:id="#+id/app_toolbar"
android:layout_width="match_parent"
android:layout_height="#dimen/actionBarSize"
android:textSize="#dimen/actionBarTextSize"
android:background="#color/colorPrimary">
</androidx.appcompat.widget.Toolbar>
<View
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="#drawable/shadow_top_to_down" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/C_makeControlMain"
android:layout_width="0dp"
android:layout_height="227dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/C_makeControlHeader"
android:layout_width="0dp"
android:layout_height="46dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="#+id/fileTitle"
android:layout_width="170dp"
android:layout_height="21dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:gravity="center"
android:text="#string/fileTitle"
app:layout_constraintEnd_toStartOf="#+id/imageButton3"
app:layout_constraintStart_toEndOf="#+id/imageButton2"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="#+id/imageButton"
android:layout_width="34dp"
android:layout_height="29dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/add_new_information" />
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="35dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageButton"
app:layout_constraintStart_toEndOf="#+id/imageButton"
app:layout_constraintTop_toTopOf="#+id/imageButton"
app:srcCompat="#drawable/save_information" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="#string/artist_name"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="#+id/fileTitle"
app:layout_constraintHorizontal_bias="0.513"
app:layout_constraintStart_toStartOf="#+id/fileTitle"
app:layout_constraintTop_toBottomOf="#+id/fileTitle" />
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="28dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageButton4"
app:layout_constraintEnd_toStartOf="#+id/imageButton4"
app:layout_constraintTop_toTopOf="#+id/imageButton4"
app:srcCompat="#drawable/add_normal_browser" />
<ImageButton
android:id="#+id/imageButton4"
android:layout_width="26dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageButton5"
app:layout_constraintEnd_toStartOf="#+id/imageButton5"
app:layout_constraintTop_toTopOf="#+id/imageButton5"
app:srcCompat="#drawable/sync_browsers" />
<ImageButton
android:id="#+id/imageButton5"
android:layout_width="29dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="#+id/imageButton2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="#+id/imageButton2"
app:srcCompat="#drawable/add_singalong_browser" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
The error is actually quite logical, and one who is much familiar with reading the logcat would've found it in 5 minute.
After you enable using the vector using the vectorDrawables.useSupportLibrary = true you have to henceforth reference all the vector images using app:srcCompat= #drawable/xyz, if any of your xml files use instead android:src="#drawable/vector then the app would crash as shown above.
Side note: The solution was as mentioned in the doc also for androidx users, just to be clear.

ConstraintLayout 1.0.2 shows nothing

I'm still having this weird problem. ConstraintLayout only works when it's on 'alpha-7', when I change it to '1.0.2' the latest version it shows nothing
Desired layout should look like this:
However, I'm getting this: "on a real HTC one M9 - CM 12.1.1"
** 'Show layout bounds' is On just so you can see that there are nothing on drawn on the device.
** I also tried with 'Show layout update' and it shows nothing as well
In the Layout Inspector the Username field, Password field and Login Button and showing:
XML layout:
<android.support.constraint.ConstraintLayout 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/fragment_login"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/login_background"
android:clickable="true"
tools:context=".ui.login_sing_up.LoginFragment">
<android.support.design.widget.TextInputLayout
android:id="#+id/login_username_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="250dp"
android:textColorHint="#color/Azure"
android:visibility="visible"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.design.widget.TextInputEditText
android:id="#+id/login_username"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_weight="1"
android:hint="#string/Username_or_Email"
android:inputType="textNoSuggestions|textEmailAddress"
android:lines="1"
android:linksClickable="false"
android:textColor="#color/Azure"
android:textColorHighlight="#color/black"
android:textColorHint="#color/Azure"
android:visibility="visible" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/login_password_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColorHint="#color/Azure"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/login_username_container"
app:passwordToggleEnabled="true">
<android.support.design.widget.TextInputEditText
android:id="#+id/login_password"
android:layout_width="300dp"
android:layout_height="50dp"
android:layout_gravity="center"
android:layout_weight="1"
android:hint="#string/password"
android:inputType="textPassword"
android:lines="1"
android:linksClickable="false"
android:textColor="#color/Azure"
android:textColorHighlight="#color/black"
android:textColorHint="#color/Azure" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/login_login"
style="#style/Base.Widget.AppCompat.Button.Colored.login"
android:layout_width="150dp"
android:layout_height="50dp"
android:layout_marginTop="8dp"
android:text="#string/login"
app:layout_constraintLeft_toLeftOf="#+id/login_password_container"
app:layout_constraintRight_toRightOf="#+id/login_password_container"
app:layout_constraintTop_toBottomOf="#+id/login_password_container" />
</android.support.constraint.ConstraintLayout>
LogCat shows nothing
07-20 20:00:01.028 7144-7144/? I/art: Late-enabling -Xcheck:jni
07-20 20:00:01.083 7144-7158/? E/art: Failed sending reply to debugger: Broken pipe
07-20 20:00:01.084 7144-7158/? I/art: Debugger is no longer active
07-20 20:00:03.344 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx I/LoadedApk: No resource references to update in package common
07-20 20:00:03.344 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx I/LoadedApk: No resource references to update in package com.brit.swiftdark
07-20 20:00:03.346 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx I/InstantRun: starting instant run server: is main process
07-20 20:00:03.473 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx W/ResourceType: For resource 0x01030224, entry index(548) is beyond type entryCount(29)
07-20 20:00:03.473 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx W/ResourceType: For resource 0x01030224, entry index(548) is beyond type entryCount(29)
07-20 20:00:03.511 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
07-20 20:00:03.614 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/DispatcherActivity: there is no user
07-20 20:00:03.621 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/UserCoordinator: making new Instance
07-20 20:00:03.652 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/DispatcherActivity: checking if there is user in Pref
07-20 20:00:03.653 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/DispatcherActivity: there is no user in Pref
07-20 20:00:03.653 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/DispatcherActivity: there is no user
07-20 20:00:03.658 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/DispatcherActivity: createFragment-LoginFragment
07-20 20:00:03.856 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/LoginFragment: creating ver
07-20 20:00:03.856 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/LoginFragment: done creating ver
07-20 20:00:03.861 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/DispatcherActivity: onResume
07-20 20:00:03.861 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/DispatcherActivity: onResume - null == mUC
07-20 20:00:03.861 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/UserCoordinator: got Instance from preferences
07-20 20:00:03.862 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/UserCoordinator: get userCoordinator
07-20 20:00:03.873 7144-7249/xxxxxxxxxxx.xxxxxxxxxxxxx D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true
07-20 20:00:03.877 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx D/Atlas: Validating map...
07-20 20:00:03.878 7144-7169/xxxxxxxxxxx.xxxxxxxxxxxxx W/Binder: Caught a RuntimeException from the binder stub implementation.
java.lang.NullPointerException: Attempt to read from field 'android.view.HardwareRenderer android.view.View$AttachInfo.mHardwareRenderer' on a null object reference
at android.view.WindowManagerGlobal.dumpGfxInfo(WindowManagerGlobal.java:476)
at android.app.ActivityThread$ApplicationThread.dumpGfxInfo(ActivityThread.java:1089)
at android.app.ApplicationThreadNative.onTransact(ApplicationThreadNative.java:546)
at android.os.Binder.execTransact(Binder.java:446)
07-20 20:00:03.944 7144-7249/xxxxxxxxxxx.xxxxxxxxxxxxx I/Adreno: QUALCOMM build : 065751b,
Build Date : 04/15/15
OpenGL ES Shader Compiler Version: E031.25.03.07
Local Branch :
Remote Branch : quic/LA.BF64.1.2.1_rb2.9
Remote Branch : NONE
Reconstruct Branch : AU_LINUX_ANDROID_LA.BF64.1.2.1_RB2.05.01.00.081.016 + 065751b + NOTHING
07-20 20:00:03.967 7144-7249/xxxxxxxxxxx.xxxxxxxxxxxxx I/OpenGLRenderer: Initialized EGL, version 1.4
07-20 20:00:03.989 7144-7249/xxxxxxxxxxx.xxxxxxxxxxxxx D/OpenGLRenderer: Enabling debug mode 0
07-20 20:00:04.121 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy#3781b87d time:768477070
07-20 20:00:04.130 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
07-20 20:00:04.130 7144-7144/xxxxxxxxxxx.xxxxxxxxxxxxx E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
build.gradle
repositories {
jcenter();
}
dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
Things I tried:
Invalidating and restarting Android studio.
Tried on an emulator.
Tried on a Huawei Device.
Tried on an HTC one M9 Device.
Rolling back to 'Alpha-7' works fine.
Please if you need any more details let me know in the comment
After a year of waiting for a real explanation of what is going on and what happened after 'Alpha-7', I "Kindaaa~"figured it out.
The Short Answer
Activities with ConstraintLayout will do fine. however if you are adding a fragment on top, then make sure to make the activity background transparent.

"Detected prob_lem with app native libraries" message on certain phones

Everytime I run the app, I get this error message. There is nothing in the app, it is just a basic Navigation drawer template you get in the studio. The message only appears on certain devices (I ran it on a Zenfone 2 with Lineage OS(7.1.1)). My SDK version is 25 and I'm running android studio 2.3.1.
The message says:
Detected problems with app native libraries (please consult log for details):
libavcodec.so: text relocations
libswresample.so: text relocations
Log:
04-08 21:53:06.321 6798-6798/? I/art: Late-enabling -Xcheck:jni
04-08 21:53:06.482 6798-6798/com.platformpetal.platformpetal W/System: ClassLoader referenced unknown path: /data/app/com.platformpetal.platformpetal-1/lib/x86
04-08 21:53:06.494 6798-6798/com.platformpetal.platformpetal I/InstantRun: starting instant run server: is main process
04-08 21:53:06.664 6798-6831/com.platformpetal.platformpetal I/OpenGLRenderer: Initialized EGL, version 1.4
04-08 21:53:06.664 6798-6831/com.platformpetal.platformpetal D/OpenGLRenderer: Swap behavior 1
04-08 21:53:06.665 6798-6831/com.platformpetal.platformpetal W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
04-08 21:53:06.665 6798-6831/com.platformpetal.platformpetal D/OpenGLRenderer: Swap behavior 0
04-08 21:53:08.704 6798-6798/com.platformpetal.platformpetal W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
04-08 21:53:09.158 6798-6798/com.platformpetal.platformpetal W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
04-08 21:53:09.598 6798-6798/com.platformpetal.platformpetal E/WindowManager: android.view.WindowLeaked: Activity com.platformpetal.platformpetal.SplashScreen has leaked window DecorView#aaf4c69[] that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:418)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:331)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
at android.app.Dialog.show(Dialog.java:322)
at android.app.AlertDialog$Builder.show(AlertDialog.java:1112)
at android.app.Activity.performStart(Activity.java:6718)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2628)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6126)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776
)
Here the error message is for the activity being terminated before the message closes. There is nothing I can find which can cause the issue.
P.S. Stack Overflow doesn't allow word problem in question, so I wrote prob_lem
P.P.S. I'm relatively new to android, so don't be harsh :)
This is documented in https://developer.android.com/about/versions/nougat/android-7.0-changes.html#ndk => you need to bundle those .so files with your application, apparently.

Error while trying to run admob ad on Android Studio

I am trying to install an admob ad on my webview app that I developed with Android Studio but the app keeps crashing now and I can't seem to get the code right.... everywhere I read about the Android SDK is different information....
This is the error I keep getting and I can't seem to figure out why I am getting it..
03-17 02:31:31.637 15034-15034/? I/SELinux: Function: selinux_android_load_priority [0], There is no sepolicy file.
03-17 02:31:31.697 15034-15034/? I/SELinux: Function: selinux_android_load_priority , spota verifySig and checkHash pass. priority version is VE=SEPF_SGH-I527M_4.4.2_0046
03-17 02:31:31.697 15034-15034/? I/SELinux: selinux_android_seapp_context_reload: seapp_contexts file is loaded from /data/security/spota/seapp_contexts
03-17 02:31:31.697 15034-15034/? D/dalvikvm: Late-enabling CheckJNI
03-17 02:31:32.127 15034-15034/com.payforlikes.app.payforlikes I/dalvikvm-heap: Grow heap (frag case) to 23.093MB for 14791732-byte allocation
03-17 02:31:32.278 15034-15034/com.payforlikes.app.payforlikes I/Adreno-EGL: <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build: (CL3869936) OpenGL ES Shader Compiler Version: 17.01.12.SPL Build Date: 03/03/14 Mon Local Branch: default Remote Branch: Local Patches: Reconstruct Branch:
03-17 02:31:32.428 15034-15034/com.payforlikes.app.payforlikes D/OpenGLRenderer: Enabling debug mode 0
03-17 02:31:33.339 15034-15034/com.payforlikes.app.payforlikes E/OpenGLRenderer: SFEffectCache:clear(), mSize = 0
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes I/dalvikvm: Could not find method android.view.Window$Callback.onProvideKeyboardShortcuts, referenced from method android.support.v7.view.WindowCallbackWrapper.onProvideKeyboardShortcuts
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes W/dalvikvm: VFY: unable to resolve interface method 19659: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;)V
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes I/dalvikvm: Could not find method android.view.Window$Callback.onSearchRequested, referenced from method android.support.v7.view.WindowCallbackWrapper.onSearchRequested
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes W/dalvikvm: VFY: unable to resolve interface method 19661: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes I/dalvikvm: Could not find method android.view.Window$Callback.onWindowStartingActionMode, referenced from method android.support.v7.view.WindowCallbackWrapper.onWindowStartingActionMode
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes W/dalvikvm: VFY: unable to resolve interface method 19665: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes D/dalvikvm: VFY: replacing opcode 0x72 at 0x0002
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes I/dalvikvm: Could not find method android.content.res.TypedArray.getChangingConfigurations, referenced from method android.support.v7.widget.TintTypedArray.getChangingConfigurations
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes W/dalvikvm: VFY: unable to resolve virtual method 545: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes D/dalvikvm: VFY: replacing opcode 0x6e at 0x0002
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes I/dalvikvm: Could not find method android.content.res.TypedArray.getType, referenced from method android.support.v7.widget.TintTypedArray.getType
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes W/dalvikvm: VFY: unable to resolve virtual method 567: Landroid/content/res/TypedArray;.getType (I)I
03-17 02:31:35.271 15034-15034/com.payforlikes.app.payforlikes D/dalvikvm: VFY: replacing opcode 0x6e at 0x0008
03-17 02:31:35.351 15034-15034/com.payforlikes.app.payforlikes V/WebViewChromium: Binding Chromium to the background looper Looper (main, tid 1) {41ea0198}
03-17 02:31:35.391 15034-15034/com.payforlikes.app.payforlikes I/chromium: [INFO:library_loader_hooks.cc(112)] Chromium logging enabled: level = 0, default verbosity = 0
03-17 02:31:35.391 15034-15034/com.payforlikes.app.payforlikes I/BrowserProcessMain: Initializing chromium process, renderers=0
03-17 02:31:35.521 15034-15034/com.payforlikes.app.payforlikes I/Adreno-EGL: <qeglDrvAPI_eglInitialize:381>: EGL 1.4 QUALCOMM build: (CL3869936) OpenGL ES Shader Compiler Version: 17.01.12.SPL Build Date: 03/03/14 Mon Local Branch: default Remote Branch: Local Patches: Reconstruct Branch:
03-17 02:31:35.531 15034-15257/com.payforlikes.app.payforlikes W/chromium: [WARNING:proxy_service.cc(888)] PAC support disabled because there is no system implementation
03-17 02:31:35.731 15034-15034/com.payforlikes.app.payforlikes W/Ads: Required XML attribute "adSize" was missing.
03-17 02:31:35.992 15034-15034/com.payforlikes.app.payforlikes D/AndroidRuntime: Shutting down VM
03-17 02:31:35.992 15034-15034/com.payforlikes.app.payforlikes W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x416cdda0)
03-17 02:31:36.002 15034-15034/com.payforlikes.app.payforlikes E/AndroidRuntime: FATAL EXCEPTION: main Process: com.payforlikes.app.payforlikes, PID: 15034 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.payforlikes.app.payforlikes/com.payforlikes.app.payforlikes.MainActivity}: java.lang.IllegalStateException: The ad size and ad unit ID must be set before loadAd is called.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2413)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471)
at android.app.ActivityThread.access$900(ActivityThread.java:175)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5602)
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:1283)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException: The ad size and ad unit ID must be set before loadAd is called.
at com.google.android.gms.ads.internal.client.zzab.zzdg(Unknown Source)
at com.google.android.gms.ads.internal.client.zzab.zza(Unknown Source)
at com.google.android.gms.ads.BaseAdView.loadAd(Unknown Source)
at com.google.android.gms.ads.AdView.loadAd(Unknown Source)
at com.payforlikes.app.payforlikes.MainActivity.onCreate(MainActivity.java:55)
at android.app.Activity.performCreate(Activity.java:5451)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2377)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2471) 
at android.app.ActivityThread.access$900(ActivityThread.java:175) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1308) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:146) 
at android.app.ActivityThread.main(ActivityThread.java:5602) 
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:1283) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099) 
at dalvik.system.NativeStart.main(Native Method) 
Here is my activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.payforlikes.app.payforlikes.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.payforlikes.app.payforlikes"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
} }
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
compile 'com.android.support:design:24.0.0-alpha1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
Here is my MainActivity.java
package com.payforlikes.app.payforlikes;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd; public class MainActivity extends AppCompatActivity {
InterstitialAd mInterstitialAd;
private InterstitialAd interstitial;
private static final String TEST_DEVICE_ID = "INSERT_YOUR_TEST_DEVICE_ID_HERE";
private WebView mWebView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mWebView = (WebView) findViewById(R.id.activity_main_webview);
mWebView.setWebViewClient(new WebViewClient());
// Enable Javascript
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mWebView.loadUrl("http://payforlikes.com/");
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// The "loadAdOnCreate" and "testDevices" XML attributes no longer available.
AdView adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice(TEST_DEVICE_ID)
.build();
adView.loadAd(adRequest);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void displayInterstitial() { // If Ads are loaded, show Interstitial else show nothing.
if (interstitial.isLoaded()) {
interstitial.show();
}
} }
Here is my content_main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.payforlikes.app.payforlikes.MainActivity"
tools:showIn="#layout/activity_main">
<WebView
android:id="#+id/activity_main_webview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.google.android.gms.ads.AdView android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="INSERT_YOUR_AD_UNIT_ID_HERE"/> </RelativeLayout>
Here is my AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
package="com.payforlikes.app.payforlikes">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".SplashScreen"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme.NoActionBar">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

LoginButton.java error - trouble getting started with facebook sdk on Android

i am having trouble with the facebook sdk. I use Intellij Idea, and I managed to add the sdk to the project and at least getting it compiled.
So I start with a blank project with a single activity and i add a LoginButton so that my Layout.xml looks like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, MainActivity"
/>
<com.facebook.widget.LoginButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
The first problem is, I get this message at the UI preview window:
android.content.res.Resources$NotFoundException: Could not resolve resource value: 0x7F060006.
at android.content.res.BridgeResources.throwException(BridgeResources.java:693)
at android.content.res.BridgeResources.getColor(BridgeResources.java:185)
at com.facebook.widget.LoginButton.<init>(LoginButton.java:237)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:375)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:100)
at com.android.tools.idea.rendering.ProjectCallback.loadView(ProjectCallback.java:169)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:755)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:373)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:399)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:336)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:332)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:564)
at com.android.tools.idea.rendering.RenderService$3.compute(RenderService.java:553)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
at com.android.tools.idea.rendering.RenderService.createRenderSession(RenderService.java:553)
at com.android.tools.idea.rendering.RenderService.render(RenderService.java:626)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:575)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:81)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6$1.run(AndroidLayoutPreviewToolWindowManager.java:521)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:178)
at com.intellij.openapi.progress.ProgressManager.executeProcessUnderProgress(ProgressManager.java:209)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:212)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:171)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$6.run(AndroidLayoutPreviewToolWindowManager.java:516)
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$2.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
So it looks like there is trouble with the R file, but, anyways, it still compiles.
As soon as the app runs on the emulator, it crashes with this stack:
05-02 19:15:35.073 2023-2023/com.Jam D/dalvikvm﹕ Not late-enabling CheckJNI (already on)
05-02 19:15:35.453 2023-2029/com.Jam D/dalvikvm﹕ Debugger has detached; object registry had 1 entries
05-02 19:15:36.014 2023-2023/com.Jam D/﹕ HostConnection::get() New Host Connection established 0xb91d7290, tid 2023
05-02 19:15:36.514 2023-2023/com.Jam W/EGL_emulation﹕ eglSurfaceAttrib not implemented
05-02 19:15:36.564 2023-2023/com.Jam D/OpenGLRenderer﹕ Enabling debug mode 0
05-02 19:15:36.644 2023-2036/com.Jam W/dalvikvm﹕ threadid=11: thread exiting with uncaught exception (group=0xb1d8cb20)
05-02 19:15:36.644 2023-2036/com.Jam E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
Process: com.Jam, PID: 2023
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.NullPointerException
at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:911)
at com.facebook.internal.Utility.queryAppSettings(Utility.java:372)
at com.facebook.widget.LoginButton$1.doInBackground(LoginButton.java:667)
at com.facebook.widget.LoginButton$1.doInBackground(LoginButton.java:664)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
I am new to Android so I have no clue what to do. I mean, my code will throw all sorts of exceptions :p but I have no clue as I why facebook SDK code would throw a null exception.
I was also facing same problem:
I was putting my app id as this:
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="MY_APP_ID"/>
but what it should have been:
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
I never thought this could create such an error. They should put this as warning in their tutorial I guess!
Give it a try. If this is not the solution then it should be something related to App ID. You might not have added keyhash to your app. Follow each step in this tutorial and don't skip any.
If it still doesn't solve the problem compare facebook related with facebook samples packed with the SDK.
Good Luck!
I faced this same problem some time back and for me the problem had to do with wrong meta data name. Make sure you get it right.
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id"/>
instead of
<meta-data android:name="com.facebook.sdk.Application" android:value="#string/facebook_app_id"/>

Categories

Resources