Я создаю простое приложение для проверки AppCompat
, когда я расширяю AppCompatActivity
приложение вылетает, и когда я запускаю приложение без AppCompat
(расширение android.app.Activity
и все остается прежним),
MainActivity extends Activity
- работает
MainActivity extends AppCompat Activity
- вылетает
Тестирование на android 4.4
LogCat:
------------------------------------------------
05-01 23:03:44.916 E/dalvikvm(23031): heapsize Dalvik_dalvik_system_VMRuntime_nativeMinimumHeapSize 0
05-01 23:03:44.916 E/dalvikvm(23031): heapsize Dalvik_dalvik_system_VMRuntime_nativeMinimumHeapSize 15301176
05-01 23:03:44.966 E/dalvikvm(23031): Could not find class 'android.arch.core.internal.FastSafeIterableMap', referenced from method android.arch.lifecycle.LifecycleRegistry.<init>
05-01 23:03:44.986 E/AndroidRuntime(23031): FATAL EXCEPTION: main
05-01 23:03:44.986 E/AndroidRuntime(23031): Process: com.android.xDrawer, PID: 23031
05-01 23:03:44.986 E/AndroidRuntime(23031): java.lang.NoClassDefFoundError: android.arch.core.internal.FastSafeIterableMap
05-01 23:03:44.986 E/AndroidRuntime(23031): at android.arch.lifecycle.LifecycleRegistry.<init>(LifecycleRegistry.java:59)
05-01 23:03:44.986 E/AndroidRuntime(23031): at android.support.v4.app.SupportActivity.<init>(SupportActivity.java:47)
05-01 23:03:44.986 E/AndroidRuntime(23031): at android.support.v4.app.BaseFragmentActivityApi14.<init>(BaseFragmentActivityApi14.java:28)
05-01 23:03:44.986 E/AndroidRuntime(23031): at android.support.v4.app.BaseFragmentActivityApi16.<init>(BaseFragmentActivityApi16.java:34)
05-01 23:03:44.986 E/AndroidRuntime(23031): at android.support.v4.app.FragmentActivity.<init>(FragmentActivity.java:68)
05-01 23:03:44.986 E/AndroidRuntime(23031): at android.support.v7.app.AppCompatActivity.<init>(AppCompatActivity.java:61)
05-01 23:03:44.986 E/AndroidRuntime(23031): at com.android.xDrawer.MainActivity.<init>(MainActivity.java:49)
05-01 23:03:44.986 E/AndroidRuntime(23031): at java.lang.Class.newInstanceImpl(Native Method)
05-01 23:03:44.986 E/AndroidRuntime(23031): at java.lang.Class.newInstance(Class.java:1208)
-----------------------------------------
Добавление
vectorDrawables.useSupportLibrary = true
В приложениях проблемы не решили
Обновление:
Полный файл Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId "com.mycompany.myapp"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:appcompat-v7:27.1.1"
}
Активность:
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
Xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:text="@string/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
Стили:
<resources>
<style name="AppTheme" parent="@style/Theme.AppCompat.Light">
</style>
</resources>