I'm trying to get Buck working with the balnk 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
android_prebuilt_aar(
name = 'appcompat-v7',
aar = 'appcompat-v7-23.0.1.aar',
visibility = ['PUBLIC']
)
android_prebuilt_aar(
name = 'design',
aar = 'design-23.0.1.aar',
visibility = ['PUBLIC']
)
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
EDIT: my apk contains the CoordinatorLayout class in its dex file btw
EDIT2: full code can be found here https://github.com/vinz243/snappy
EDIT3: tried extending from AppCompatActivity:
vinz243@vm:~/snappy$ buck build app
[-] PROCESSING BUCK FILES...FINISHED 0.1s [100%]
[+] DOWNLOADING... (0.00 B/S, TOTAL: 0.00 B, 0 Artifacts)
[+] BUILDING...0.3s [67%] (16/20 JOBS, 0 UPDATED, 0.0% CACHE MISS)
|=> IDLE
|=> IDLE
|=> //java:main... 0.2s (running javac[0.2s])
|=> IDLE
/home/vinz243/snappy/java/com/whitedrop/snappy/MainActivity.java:12: error: cannot access android.support.v4.app.TaskStackBuilder
public class MainActivity extends AppCompatActivity {
^
class file for android.support.v4.app.TaskStackBuilder not found
/home/vinz243/snappy/java/com/whitedrop/snappy/MainActivity.java:14: error: method does not override or implement a method from a supertype
@Override
^
/home/vinz243/snappy/java/com/whitedrop/snappy/MainActivity.java:16: error: cannot find symbol
super.onCreate(savedInstanceState);
^
symbol: variable super
location: class com.whitedrop.snappy.MainActivity
/home/vinz243/snappy/java/com/whitedrop/snappy/MainActivity.java:17: error: cannot find symbol
setContentView(R.layout.activity_main);
^
symbol: method setContentView(int)
location: class com.whitedrop.snappy.MainActivity
/home/vinz243/snappy/java/com/whitedrop/snappy/MainActivity.java:20: error: method does not override or implement a method from a supertype
@Override
^
/home/vinz243/snappy/java/com/whitedrop/snappy/MainActivity.java:23: error: cannot find symbol
getMenuInflater().inflate(R.menu.activity_main, menu);
^
symbol: method getMenuInflater()
location: class com.whitedrop.snappy.MainActivity
Errors: 6. Warnings: 0.
Here is the MainActivity.java:
package com.whitedrop.snappy;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}
EDIT 5:
Fixed above error by adding support v4 to deps. Now I get when running:
E java.lang.RuntimeException: Unable to start activity ComponentInfo{com.whitedrop.snappy/com.whitedrop.snappy.MainActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar
E at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
E Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.v7.widget.Toolbar
E at android.view.LayoutInflater.createView(LayoutInflater.java:633)
E Caused by: java.lang.reflect.InvocationTargetException
E at java.lang.reflect.Constructor.newInstance(Native Method)
E at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
E at android.view.LayoutInflater.createView(LayoutInflater.java:607)
E ... 24 more
E Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/graphics/drawable/VectorDrawableCompat;
E at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:891)
E Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.graphics.drawable.VectorDrawableCompat" 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)
Make sure the versions you've mentioned in your BUCK
config are correct.
In the code you've shared in your question i see v23.0.1
for support and design libraries. In your github repository I see v23.4.0
.
I'm suspecting this is the reason. Change to the correct version you've included in your libs folder and see if it works.
Update in response to edit 5 in your question:
The following two dependencies will help resolve the VectorDrawableCompat ClassNotFoundException
. Include them in a suitable way for BUCK.
compile 'com.android.support:support-vector-drawable:23.4.0'
compile 'com.android.support:animated-vector-drawable:23.4.0'