Cetnix
Lurker
Hello everyone, I'm building a utility app with ads. I'm currently having a problem at the build.gradle(app) choosing the correct compilesdk,buildtoolsversion and targetsdkversion. Can you help me out? Thanks.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Can you try to update your sdk version to atleast v27Hello everyone, I'm building a utility app with ads. I'm currently having a problem at the build.gradle(app) choosing the correct compilesdk,buildtoolsversion and targetsdkversion. Can you help me out? Thanks.
Hello everyone, I'm building a utility app with ads. I'm currently having a problem at the build.gradle(app) choosing the correct compilesdk,buildtoolsversion and targetsdkversion. Can you help me out? Thanks.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.YOUR.APP.HERE"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
}
buildToolsVersion '28.0.3'
implementation 'androidx.appcompat:appcompat:1.0.2'
</li>Please try to post code instead of images as it's easier to sort through and help you.
I looked through a couple of the images and seems you need some adjustments and you'll be fine. I'll post what a newly created project should look like for you to reference.
The build.gradle file in the root of your project should be exactly as follows...
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'><tt>// Top-level build file where you can add configuration options common to all sub-projects/modules. </tt></li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>buildscript { </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; repositories { </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; google() </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; jcenter() </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; } </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; dependencies { </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; classpath 'com.android.tools.build:gradle:3.3.0' </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; // NOTE: Do not place your application dependencies here; they belong </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; // in the individual module build.gradle files </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; } </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>} </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>allprojects { </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; repositories { </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; google() </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; jcenter() </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; } </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>} </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>task clean(type: Delete) { </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; delete rootProject.buildDir </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>} </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>[/LIST] Now as for the build.gradle file in your app directory you should targetSdkVersion 28 which is the latest. Your appcompat should be v7:28.0.0, also the latest. Here's the build.gradle from a working sample project for you to reference... </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'><tt>apply plugin: 'com.android.application' </tt></li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>android { </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; compileSdkVersion 28 </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; defaultConfig { </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; applicationId 'com.YOUR.APP.HERE' </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; minSdkVersion 15 </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; targetSdkVersion 28 </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; versionCode 1 </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; versionName '1.0' </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; } </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; buildTypes { </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; release { </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; &#160; &#160; minifyEnabled true </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; &#160; &#160; shrinkResources true </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; &#160; &#160; proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; &#160; &#160; } </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; } </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>} </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>dependencies { </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; implementation fileTree(dir: 'libs', include: ['*.jar']) </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>&#160; &#160; implementation 'com.android.support:appcompat-v7:28.0.0' </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>} </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>[/LIST] New created projects in the latest version of Android Studio don't seem to use buildToolsVersion in the build.gradle, but if you need it, this is the latest... </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'><tt>buildToolsVersion '28.0.3' </tt></li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>[/LIST] If you set minifyEnabled and shrinkResources to true you may get some build errors if you use Adsense and/or ShareActionProvider. This can easily be fixed with some proguard rules. Have a look at the tutorial in this link for how to do it... </li>
<li dir='ltr'>https://intechgeek.com/reduce-apk-size/ </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>One thing you should be aware of is that the appcompat support library will according to google, not be updated past version 28 and will eventually be deprecated. Instead you should be making the switch to the AndroidX appcompat support library. </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>To use the AndroidX library just change your dependency to this... </li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'><tt>implementation 'androidx.appcompat:appcompat:1.0.2' </tt></li>
</ul>
<ul style='margin-top:0; margin-bottom:0;'>
<li dir='ltr'>[/LIST] Read about the AndroiX library and benefits here... </li>
<li dir='ltr'>https://developer.android.com/jetpack/androidx/
Can you try to update your sdk version to atleast v27
</li>
</ul>
Add this to your .bashrc file:
export LC_ALL=C
I suggest this because of certain changes made in Repo's newer than Nougat 7.1 (SDK #25) and distro's newer than Ubuntu 16.04 makes harder for gradle to find & build apps properly without some kind of path directory
Don't try to make his job harder with less ppl to be able to make use of his app SDK25 should be decent enough cuz lots of ppl still on Nougat
Please try to post code instead of images as it's easier to sort through and help you.
I looked through a couple of the images and seems you need some adjustments and you'll be fine. I'll post what a newly created project should look like for you to reference.
The build.gradle file in the root of your project should be exactly as follows...
Code:// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir }
Now as for the build.gradle file in your app directory you should targetSdkVersion 28 which is the latest. Your appcompat should be v7:28.0.0, also the latest. Here's the build.gradle from a working sample project for you to reference...
Code:apply plugin: 'com.android.application' android { compileSdkVersion 28 defaultConfig { applicationId "com.YOUR.APP.HERE" minSdkVersion 15 targetSdkVersion 28 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' }
New created projects in the latest version of Android Studio don't seem to use buildToolsVersion in the build.gradle, but if you need it, this is the latest...
Code:buildToolsVersion '28.0.3'
If you set minifyEnabled and shrinkResources to true you may get some build errors if you use Adsense and/or ShareActionProvider. This can easily be fixed with some proguard rules. Have a look at the tutorial in this link for how to do it...
https://intechgeek.com/reduce-apk-size/
One thing you should be aware of is that the appcompat support library will according to google, not be updated past version 28 and will eventually be deprecated. Instead you should be making the switch to the AndroidX appcompat support library.
To use the AndroidX library just change your dependency to this...
Code:implementation 'androidx.appcompat:appcompat:1.0.2'
Read about the AndroiX library and benefits here...
https://developer.android.com/jetpack/androidx/