I am developing an application that uses AppCompatActivity. On api 21+, everything works fine, but the application does not run on api 19 or less with the message the distance is stopped. I want api less than 19 to use material design.

Activity_main.xml file

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/activity_main" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="tj.rs.materialdesignexample.MainActivity"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!"/> <Button android:text="Button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/button" android:layout_centerVertical="true" android:layout_centerHorizontal="true"/> </RelativeLayout> 

Gradle.build file

 apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "28.0.1" defaultConfig { applicationId "tj.rs.materialdesignexample" minSdkVersion 17 targetSdkVersion 22 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:22.2.1' testCompile 'junit:junit:4.12' } 

File MainActivity.java

 package tj.rs.materialdesignexample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } 
  • 2
    "Application stopped" is, of course, informative, but I would like to see the logs. - Enikeyschik
  • one
    Try adding design and support libraries for implementation 'com.android.support:support-v4:22.2.1' implementation 'com.android.support:design:22.2.1' under your compile 'com.android.support:appcompat-v7:22.2.1' - McDaggen

1 answer 1

During construction, the Android toolkit takes your resources, code, and AndroidManifest.xml file (containing the application's metadata) and converts them into an .apk file. The resulting file is signed with a debug key, which allows it to run in the emulator. (To distribute the .apk file to users, you must sign it with the publication key. For more information about this process, see the Android developer documentation at http://developer.android.com/tools/publishing/preparing.html .)

You must sign the apk with the publication key.