buck icon indicating copy to clipboard operation
buck copied to clipboard

Didn't find class “android.support.design.widget.CoordinatorLayout” using Buck

Open vinz243 opened this issue 10 years ago • 6 comments

Hi everyone,

I'm trying to get Buck working with the blank application template from Android Studio.

apps/snappy/BUCK

    android_binary(
      name = 'main',
      manifest = 'AndroidManifest.xml',
      keystore = '//keystores:debug',
      package_type = 'debug',
      deps = [
        '//java:main',
        '//res:res',
        '//keystores:debug',
      ],
    )

res/snappy/layout/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.whitedrop.snappy.MainActivity">

        ....

    </android.support.design.widget.CoordinatorLayout>

res/BUCK

    android_resource(
      name = 'res',
      res = 'snappy',
      package = 'com.whitedrop.snappy',
      deps = [
      '//libs:appcompat-v7',
      '//libs:design'
      ],
      visibility = [
        'PUBLIC',
      ]
    )

libs/BUCK

local_maven('com.android.support:design:23.4.0')
local_maven('com.android.support:appcompat-v7:23.4.0')

DEFS

sdkPath = '/home/vinz243/android-sdk'
def local_maven(pkg):
    group, name, version = pkg.split(':', 3)
    file = (sdkPath + '/extras/android/m2repository/'
        + group.replace('.', '/') + '/' + name + '/' + version + '/' + name
        + '-' + version + '.aar')
    target = name + '-' + version +'.aar'

    if not os.path.isfile(target):
        copyfile(file, 'libs/' + target)

    android_prebuilt_aar(
      name = name,
      aar = target,
      visibility = ['PUBLIC']
    )

output

                    Process com.whitedrop.snappy created for activity com.whitedrop.snappy/.MainActivity
                    PID: 2449   UID:    GIDs: 

ActivityManager  I  Start proc 2449:com.whitedrop.snappy/u0a61 for activity com.whitedrop.snappy/.MainActivity
            art  I  Rejecting re-init on previously-failed class java.lang.Class<android.support.design.widget.CoordinatorLayout>
 AndroidRuntime  D  Shutting down VM
                 E  FATAL EXCEPTION: main
                 E  Process: com.whitedrop.snappy, PID: 2449
                 E  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.whitedrop.snappy/com.whitedrop.snappy.MainActivity}: android.view.InflateExcept
                    ion: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
                 ...E      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                 E      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                 E  Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.widget.CoordinatorLayout
                 E      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
                 ....
                 E      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
                 E      ... 10 more
                 E  Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.CoordinatorLayout" on path: DexPathList[[zip file "/data
                    /app/com.whitedrop.snappy-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
                 E      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                 ...
                 E      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
                 E      ... 19 more
                 E      Suppressed: java.lang.NoClassDefFoundError: android.support.design.widget.CoordinatorLayout
                 E          at dalvik.system.DexFile.defineClassNative(Native Method)
                 E ....     at dalvik.system.DexPathList.findClass(DexPathList.java:321)
                 E          at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
                 E          ... 23 more
                 E      Suppressed: java.lang.ClassNotFoundException: android.support.design.widget.CoordinatorLayout
                 E          at java.lang.Class.classForName(Native Method)
                 E          at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                 E          at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                 E          at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                 E          ... 22 more
                 E      Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
ActivityManager  W    Force finishing activity 1 com.whitedrop.snappy/.MainActivity

My generated APK contains the CoordinatorLayout class in its dex file btw Full code can be found here https://github.com/vinz243/snappy Original Post Thanks indvance

vinz243 avatar Jun 12 '16 19:06 vinz243

The linked SO thread does contain a solution to this issue. It seems to me that this was a misconfiguration problem rather than something wrong with Buck.

rzsombor avatar Aug 20 '16 23:08 rzsombor

Idk how, but I fixed this issue a long time ago.

vinz243 avatar Aug 21 '16 11:08 vinz243

@vinz243 please can you help me to fix the same issue. it make me crazy i checked all my code but i don't catch any error. please it'll be so kind of you.

here is my question in stackoverflow : http://stackoverflow.com/questions/39978219/inflateexception-error-inflating-class-android-support-design-widget-coordinator

abdoutech93 avatar Oct 11 '16 23:10 abdoutech93

Here is the SO post:

http://stackoverflow.com/questions/37681117/didnt-find-class-android-support-design-widget-coordinatorlayout-using-buck

vinz243 avatar Oct 13 '16 08:10 vinz243

thank you, i found the solution, i just add the theme definition in the file theme-21. thank you very match.

abdoutech93 avatar Oct 13 '16 15:10 abdoutech93

can you please clarify how you solved it, I'm struggling with the same problem !!

Waed93 avatar Jul 19 '18 07:07 Waed93