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`
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 an problem
My gradle setting
build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "hanium.project.androidapp_picturehawk"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
/*
* native build settings: taking default for almost everything
*/
ndk {
moduleName = 'hello-jni'
toolchain = 'clang'
CFlags.addAll(['-Wall'])
}
productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" #
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {`enter code here`
ndk.abiFilters.add("armeabi-v7a")
}
create("arm8") {
ndk.abiFilters.add("arm64-v8a")
}
create("x86") {
ndk.abiFilters.add("x86")
}
create("x86-64") {
ndk.abiFilters.add("x86_64")
}
create("mips") {
ndk.abiFilters.add("mips")
}
create("mips-64") {
ndk.abiFilters.add("mips64")
}
// To include all cpu architectures, leaves abiFilters empty
create("all")
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
}
build.gradle(Project:~)
-------------------------------------------------------------
// 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.1.2'
classpath 'com.android.tools.build:gradle-experimental:0.7.2'
// 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
}
----------------------------------------------
but i have an error
Error:(24, 0) Gradle DSL method not found: 'ndk()'
Possible causes:<ul><li>The project 'AndroidApp_PictureHawk' may be using a version of Gradle that does not contain the method.`enter code here`
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
what should I do??
please help me
Read your error message!
Possible causes:<ul><li>The project 'AndroidApp_PictureHawk' may be using a version of Gradle that does not contain the method.`enter code here`
Then look for and remove enter code here:
productFlavors {
// for detailed abiFilter descriptions, refer to "Supported ABIs" #
// https://developer.android.com/ndk/guides/abis.html#sa
create("arm") {
ndk.abiFilters.add("armeabi")
}
create("arm7") {`enter code here`
ndk.abiFilters.add("armeabi-v7a")
}
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'
}
}
}
I am trying to run a project that I found on github, This is the link to the project. I tried to put it in android studio, Unfortunately I cant create a configuration to run for that project. Its a library project. How can I install it. There is no modules appearing for this project. This is the gradle file
buildscript {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
classpath "gradle.plugin.nl.javadude.gradle.plugins:license-gradle-plugin:0.12.1"
}
}
allprojects {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
}
apply plugin: 'com.android.library'
apply plugin: "com.github.hierynomus.license"
license {
license {
header = file('HEADER.txt')
skipExistingHeaders = true
ignoreFailures = false
}
}
android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
}
buildTypes {
release {
minifyEnabled false
}
}
lintOptions {
disable 'InvalidPackage'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.1-1'
}
def isReleaseBuild() {
return project.VERSION_NAME.contains("SNAPSHOT") == false
}
apply from: './maven_push.gradle'
Since it is a library you can only run with a app that you are developing and not run it as stand alone.