I'm trying to compile an .apk from source code at API level 28 (compileSdkVersion 28). The app compiles fine but after installation it crashes. My app has Admob Ads in the UI itself on various pages.
Here's my project-level build.gradle -
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
Here's my app-level build.gradle -
apply plugin: 'com.android.application'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 28
defaultConfig {
applicationId "****APP_ID****"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-ads:17.2.1'
implementation 'com.android.support:customtabs:27.0.2'
implementation 'com.google.android.gms:play-services-maps:+'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.squareup.okhttp3:okhttp:3.9.1'
}
apply plugin: 'com.google.gms.google-services'
Here's the Ad code from my AndroidManifest.xml -
<application>
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="*****ADMOB-ID*****"/>
</application>
Here's the Ad code from my MainActivity.java
import com.google.android.gms.ads.MobileAds;
public class MainActivity extends Activity {
private LinearLayout linear1;
private AdView adview1;
@Override
protected void onCreate(Bundle _savedInstanceState) {
super.onCreate(_savedInstanceState);
setContentView(R.layout.main);
initialize(_savedInstanceState);
initializeLogic();
MobileAds.initialize(this, "*****ADMOB-ID*****");
}
I'm relatively new to Android coding. What might be the problem?