Android - crash app when using support:appcompat-v7 libraries

72 views Asked by At

I am working on app and when use Activity class for extends activites it is working fine but when I add support:appcompat-v7 to dependencies and extends class from AppCompatActivity, it cause app to crash:

MainActivity.java:

package com.myapps.boardgraphic;

import android.*;
import android.content.pm.*;
import android.os.*;
import android.support.v4.app.*;
import android.support.v4.content.*;
import android.support.v7.app.*;
import android.webkit.*;

public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState)
    {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

}

}

build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "21.1.0"

    defaultConfig {
        applicationId "com.myapps.boardgraphic"
        minSdkVersion 25
        targetSdkVersion 28
        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:25.0.0"
}

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myapps.boardgraphic" >

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.Light" 
        android:resizeableActivity = "true">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

and it`s my log:

07-12 22:20:30.413 944 944 E       AndroidRuntime                               at java.lang.reflect.Method.invoke(Native Method)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
07-12 22:20:30.413 944 944 E       AndroidRuntime                               at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:351)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:320)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:281)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               at com.mapps.whiteboard.MainActivity.onCreate(MainActivity.java:19)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               at android.app.Activity.performCreate(Activity.java:7209)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               at android.app.Activity.performCreate(Activity.java:7200)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2924)
07-12 22:20:30.413 944 944 E       AndroidRuntime                               ... 11 more
07-12 22:26:56.222 1900 1900 I     apps.whiteboar                               Late-enabling -Xcheck:jni
07-12 22:26:56.383 1900 1900 W     re-initialized>                              type=1400 audit(0.0:4137): avc: denied { read } for name="u:object_r:mtk_amslog_prop:s0" dev="tmpfs" ino=342 scontext=u:r:untrusted_app_25:s0:c512,c768 tcontext=u:object_r:mtk_amslog_prop:s0 tclass=file permissive=0
07-12 22:26:56.390 1900 1900 E     libc                                         Access denied finding property "persist.vendor.sys.activitylog"
07-12 22:26:57.067 1900 1900 W     apps.whiteboar                               Class android.support.v4.app.FragmentManagerImpl failed lock verification and will run slower.
07-12 22:26:57.067 1900 1900 W     apps.whiteboar                               Common causes for lock verification issues are non-optimized dex code

Notice that I tried to use com.android.support:appcompat-v7:28.0.0 and some other versions but it still not worked.

0

There are 0 answers