I updated Android Studio and now I don't know how to implement the adds correctly. All the aplications that I did had a different structure of gradle than the one it is created now. With the code ca-app-pub-3940256099942544~3347511713 from the test ad it works fine, but if I add the code from my ad it doesn't work, message: "The interstitial ad wasn't ready yet." .
Could you please tell me how to correctly implement it?
My code:
encendido.setOnClickListener {
if (mInterstitialAd != null) {
mInterstitialAd?.show(this)
} else {
Log.d("TAG", "The interstitial ad wasn't ready yet.")
}
mediaPlayer.stop()
encendido.visibility = View.INVISIBLE
mediaPlayer = MediaPlayer.create(this, R.raw.aspiradora)
Gradle structure now:
plugins {
id 'com.android.application' version '7.2.0' apply false
id 'com.android.library' version '7.2.0' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
} ```
Gradle structure on web Admob:
buildscript {
repositories {
google()
mavenCentral()
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
Thanks!!
Related
I updated the Android Studio and Created a new project.
I'm using some dependencies from GitHub, but after sync now, I'm getting this warning. If I ignore it, the application won't get installed.
Project Level build.gradle
buildscript {
ext {
compose_version = '1.6.10'
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
}
}
plugins {
id 'com.android.application' version '7.1.0' apply false
id 'com.android.library' version '7.1.0' apply false
id 'org.jetbrains.kotlin.android' version '1.5.31' apply false
}
allprojects {
repositories {
google()
maven { url 'https://jitpack.io' }
maven {
url "https://maven.google.com"
}
// mavenCentral()
maven { url 'https://github.com/leonardocardoso/mvn-repo/raw/master/maven-deploy' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Level build.gradle
plugins {
id 'com.android.application'
}
android {
compileSdk 31
buildFeatures {
dataBinding true
}
defaultConfig {
applicationId "com.eg.eg"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$compose_version"
implementation 'com.github.scottyab:showhidepasswordedittext:0.8'
}
settings.gradle
import org.gradle.api.initialization.resolve.RepositoriesMode
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "MyPro_v02"
include ':app'
How To Resolve this issue in Android Studio latest version BumbleBee?
For newer Android Studio projects created in Android Studio Bumblebee | 2021.1.1 or newer, the JitPack repository needs to be added into the root level file settings.gradle instead of build.gradle:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
// ...
maven { url 'https://jitpack.io' }
}
}
Add this line in your settings.gradle (bumblebee version)
after add this line Rebuild Project:-
jcenter()
maven { url "https://jitpack.io" }
I`m using Android Studio for Developing Flutter Application. After I install the Kotlin plugin in Android Studion, Application is not working. Then I remove that plugin but it's not working
build.gradle file
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
dependencies {
implementation 'com.android.support:support-annotations:28.0.0'
}
Terminal
Error Message in Terminal
I have java.lang.NoClassDefFoundError: com.android.tools.idea.gradle.AndroidGradleModelexception when I run my plugin on Android Studio. When I run plugin on Intellij IDEA all ok, plugin works.
Full sample you can find on this repo
My build.gradle:
buildscript {
repositories {
maven { url 'http://dl.bintray.com/jetbrains/intellij-plugin-service' }
}
dependencies {
classpath "gradle.plugin.org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.2.11"
}
}
plugins {
id "org.jetbrains.intellij" version "0.2.11"
}
apply plugin: "org.jetbrains.intellij"
apply plugin: 'java'
apply plugin: 'application'
intellij {
version 'IC-2016.2'
plugins = ['android', 'gradle']
}
sourceCompatibility = 1.7
targetCompatibility = 1.7
repositories {
mavenCentral()
}
dependencies {
compile 'org.apache.commons:commons-io:1.3.2'
}
I tried to run my app and got this erro, help me please.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
signingConfigs {
config {
}
}
buildToolsVersion '24.0.2'
compileSdkVersion 24
buildTypes {
buildType {
signingConfig signingConfigs.config
}
}
}
dependencies {
}
ERROR:
Error:(22, 0) Could not find method android() for arguments
[build_exkifxt5bplscorlvh4v3btv2$_run_closure3#981984c] on root
project 'Recipe App' of type org.gradle.api.Project.
Add this line:
apply plugin: 'com.android.feature'
To the top of the problematic build.gradle file and sync again.
I faced same problem and SOLVED IT BY:
Open your ‘build.gradle’ file and you find the following may be your comiple version is different but I want t show the file structure.
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
}
dependencies {
}
The error happens because similar android declaration is in other build.gradle file. therefore remove both the android and dependencies.
for more details here
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.2'
dexOptions {
incremental true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile files('app/libs/junit-4.12-JavaDoc.jar')
}
apply plugin: 'maven'`enter code here`
I have developed an app on eclipse and I lately started working with android studio, when I first moved the app all the dependencies were moved smoothly without any problem,
now I am trying to add the feature to share through Facebook and twitter, but for twitter whenever I try to use any plugin in the build.gradle the manifest disappears. As shown in the code below:
build.gradle (Project: project name)
The problem is in this file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: com.android.application
buildscript {
repositories {
jcenter()
//maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
//classpath 'io.fabric.tools:gradle:1.+'
}
}
//apply plugin: 'io.fabric'
allprojects {
repositories {
jcenter()
// maven { url 'https://maven.fabric.io/public' }
}
}
/*dependencies {
compile('com.twitter.sdk.android:twitter:1.14.1#aar') {
transitive = true;
}
}
android {
sourceSets {
main {
manifest.srcFile 'app/src/main/AndroidManifest.xml'
}
}
}*/
build.gradle (Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '24.0.0 rc4'
defaultConfig {
applicationId "com.nwf.ICDLeKitab"
minSdkVersion 14
targetSdkVersion 14
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}
}
dependencies {
compile files('libs/icu4j-4_4_2_2.jar')
compile files('libs/jsoup-1.6.3.jar')
compile files('libs/ksoap2-android-assembly-2.6.0-jar-with-dependencies.jar')
compile files('libs/zip4j_1.2.6.jar')
//compile project('com.facebook:facebook-android-sdk-4.0.1')
}
Can someone explain for me what is it happening? and how should I work with Libraries and dependencies in android studio.
Thank you
You are doing it wrong. Inside buildscript, there should be only a single import. Like so:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
// do not add any more things here!
}
dependencies {
classpath 'io.fabric.tools:gradle:1.21.5'
// do not add any more things here, either!
}
}
If you want to import more libraries, add them inside your dependencies block.
So your updated build.gradle will look like:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: com.android.application
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'io.fabric'
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
allprojects {
repositories {
jcenter()
// maven { url 'https://maven.fabric.io/public' }
}
}
dependencies {
compile('com.twitter.sdk.android:twitter:1.14.1#aar') {
transitive = true;
}
// replace following with your imports
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
}
android {
sourceSets {
main {
manifest.srcFile 'app/src/main/AndroidManifest.xml'
}
}
}