This is the problem: I'm writing an application, there was a need to add a navigation drawer. Found a third-party support library. Wrote the code, no errors, but after installation the application crashes. Help! I've tried different libraries, but it's not working. If necessary, I'll provide other files.
MainActivity
package...
import...
public class MainActivity extends DrawerActivity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.e("idi", "nahui");
addProfile(
new DrawerProfile()
.setRoundedAvatar((BitmapDrawable)getResources().getDrawable(R.drawable.ic_app_icon))
.setBackground(getResources().getDrawable(R.drawable.snackbar_background))
.setName(getString(R.string.abc_action_bar_home_description))
.setDescription("HTML, CSS, JAVASCRIPT")
.setOnProfileClickListener(new DrawerProfile.OnProfileClickListener() {
@Override
public void onClick(DrawerProfile drawerProfile, long id)
{
Toast.makeText(MainActivity.this, "Clicked profile #" + id, Toast.LENGTH_SHORT).show();
}
})
);
addItem(
new DrawerItem()
.setImage(getResources().getDrawable(android.R.drawable.btn_radio))
.setTextPrimary("First")
.setOnItemClickListener(new DrawerItem.OnItemClickListener() {
@Override
public void onClick(DrawerItem drawerItem, long id, int position) {
Toast.makeText(MainActivity.this, "Clicked first item #" + id, Toast.LENGTH_SHORT).show();
}
})
);
addDivider();
addItem(
new DrawerItem()
.setImage(getResources().getDrawable(android.R.drawable.btn_star))
.setTextPrimary("Second")
.setOnItemClickListener(new DrawerItem.OnItemClickListener() {
@Override
public void onClick(DrawerItem drawerItem, long id, int position) {
Toast.makeText(MainActivity.this, "Clicked second item #" + id, Toast.LENGTH_SHORT).show();
}
})
);
}
}
build.gradle (app)
apply plugin: ...
android {
compileSdkVersion 21
buildToolsVersion "21.1.0"
defaultConfig {
applicationId ...
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:support-v4:23.2.+"
compile "com.android.support:appcompat-v7:27.1.1"
compile 'com.android.support:design:22.+.+'
compile 'com.heinrichreimersoftware:material-drawer:2.3.3'
}
LogCat
11-08 01:27:33.717 19062 19062 E AndroidRuntime FATAL EXCEPTION: main
11-08 01:27:33.717 19062 19062 E AndroidRuntime Process: net.aaaps.webdesignlearning, PID: 19062
11-08 01:27:33.717 19062 19062 E AndroidRuntime java.lang.RuntimeException: Unable to start activity ComponentInfo{net.aaaps.webdesignlearning/net.aaaps.webdesignlearning.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2969)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3047)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.app.ActivityThread.-wrap11(Unknown Source:0)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1777)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:106)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.os.Looper.loop(Looper.java:166)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:6861)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at java.lang.reflect.Method.invoke(Native Method)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:450)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
11-08 01:27:33.717 19062 19062 E AndroidRuntime Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:113)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at net.aaaps.webdesignlearning.MainActivity.onCreate(MainActivity.java:20)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.app.Activity.performCreate(Activity.java:7110)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.app.Activity.performCreate(Activity.java:7101)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
11-08 01:27:33.717 19062 19062 E AndroidRuntime at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2922)
11-08 01:27:33.717 19062 19062 E AndroidRuntime ... 9 more
11-08 01:28:28.301 19421 19421 E AndroidRuntime FATAL EXCEPTION: main
11-08 01:28:28.301 19421 19421 E AndroidRuntime Process: net.aaaps.webdesignlearning, PID: 19421
11-08 01:28:28.301 19421 19421 E AndroidRuntime java.lang.RuntimeException: Unable to start activity ComponentInfo{net.aaaps.webdesignlearning/net.aaaps.webdesignlearning.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2969)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3047)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.app.ActivityThread.-wrap11(Unknown Source:0)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1777)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:106)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.os.Looper.loop(Looper.java:166)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.app.ActivityThread.main(ActivityThread.java:6861)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at java.lang.reflect.Method.invoke(Native Method)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:450)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
11-08 01:28:28.301 19421 19421 E AndroidRuntime Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.support.v7.app.AppCompatDelegateImplBase.onCreate(AppCompatDelegateImplBase.java:113)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at net.aaaps.webdesignlearning.MainActivity.onCreate(MainActivity.java:18)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.app.Activity.performCreate(Activity.java:7110)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.app.Activity.performCreate(Activity.java:7101)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
11-08 01:28:28.301 19421 19421 E AndroidRuntime at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2922)
11-08 01:28:28.301 19421 19421 E AndroidRuntime ... 9 more
11-08 01:29:01.300 19991 19991 E AndroidRuntime FATAL EXCEPTION: main
11-08 01:29:01.300 19991 19991 E AndroidRuntime Process: net.aaaps.webdesignlearning, PID: 19991
11-08 01:29:01.300 19991 19991 E AndroidRuntime java.lang.RuntimeException: Unable to start activity ComponentInfo{net.aaaps.webdesignlearning/net.aaaps.webdesignlearning.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
11-08 01:29:01.300 19991 19991 E AndroidRuntime at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2969)
11-08 01:29:01.300 19991 19991 E AndroidRuntime at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3047)
11-08 01:29:01.300 19991 19991 E AndroidRuntime at android.app.ActivityThread.-wrap11(Unknown Source:0)