Tried importing a library and ended up with Plugin with id 'com.android.application' not found - java

I just tried importing a library into my android project and ended up with this Plugin with id 'com.android.application' not found. error. I was supposed to import "Filters.jar" file from jhlabs but accidentally imported "gradle-wrapper.jar" of another project . I am stuck here and nothing seems to work. I also accidentally deleted my project level build.gradle file, Which contained the following 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.1.2'
// 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
}
I was trying to import the library following this answer,
https://stackoverflow.com/a/35369267/9504498
I messed up apparently I have tried many solutions but nothing is working. Please, help me fix this error I am stuck here.
How can I get the project level build.gradle file back? and how can I fix this Plugin with id 'com.android.application' not found.?
Any help will be appreciated, Thanks.

You need to re-add your build.gradle to your project by following the structure of sample project which you can create from Android Studio.
Usually, the project structure is like the following:
app -> (your app module)
gradle
build.gradle -> (project build.gradle)
gradlew
gradlew.bat
local.properties
settings.gradle
The following error:
Plugin with id 'com.android.application' not found.
is because gradle can't found the plugin from your project build.gradle, so add the following code to your project build.gradle:
// 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.1.2'
// 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
}
For adding a jar library, as #daniel-nugent says, try:
How to manually include external aar package using new Gradle Android Build System

Tried many options but nothing really worked and finally, created a new project with exact name as the previous one and the exact package name, then copied the "main" from the previous project to the new project and edited the app level build.gradle by copying from the previous project and things are back to normal now. Will try importing the .jar library by following #daniel-nugent method.

Related

How does Android search for dependencies on GitHub?

i want to implement a dependency from GitHub in my android project but it gives me this error
Could not find com.github.RobertApikyan:SegmentedControl:1.2.0
I'm implementing this:
implementation 'com.github.RobertApikyan:SegmentedControl:1.2.0'
I think is the case because by build.gradle file doesn't search on GitHub for repos.
This is my build.gradle file:
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 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
}
Workaround 1:
You can host a project release into mavenCentral using github, it is located at:
https://github.com/{user}/{repository}/packages?package_type=Maven
And in order to pull packages from it, add new repository in your build.gradle:
mavenCentral()
Wordaround 2:
You can host your project's any branch or version at jitpack.io
and the great thing is that you don't need to setup anything it'll build your packages in their server and notify you. Your project will be located at:
https://jitpack.io/#{user}/{repository}
And in order to pull packages from it, add new repository in your build.gradle:
maven { url 'https://jitpack.io' }

ERROR: Could not find com.android.tools.build:gradle:3.2.1

when I want to open or run a project , I get error below :
ERROR: Could not find com.android.tools.build:gradle:3.2.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar
Required by:
project :
Open File
and this is my build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// 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
}
also by deffault , it contains google repo but the error is there .
I am running on ubuntu 19.1 , and follow the instructions but unfortunetly I can not solve this.
Thanks to Community.
I remember facing such problems, and surprisingly found out that I have network problem!
Here are steps may help you:
- check your system proxy settings.
- then, File -> invalid Cashes/Restart.
clear gradle cache
rm -rf $HOME/.gradle/caches
and resync to download all dependencies
Go Settings/Gradle/Android Studio. Then check "Enable embedded Maven repository". And you're good to go.
Try classpath 'com.android.tools.build:gradle:3.5.3'
also an unrelated addition, Kotlin is -> ext.kotlin_version = '1.3.61'

Error in syncing dependency in android studio like Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'

Gradle is unable to resolve the com.android.support:design-v7:27.1.1 dependency, and I get the following error in Android Studio:
Failed to resolve: com.android.support:design-v7:27.1.1
enter image description here
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
There is no such artifact as com.android.support:design-v7:27.1.1. Gradle couldn't download (resolve) this dependency since it's not valid and not present in the maven repository.
Instead try this com.android.support:design:27.1.1, since this is the actual artifact.
Change this in your build.gradle and sync again. This should fix the issue.
EDIT:
The compile is obsolete and use implementation is not the issue here. But please use implementation instead of compile.
Try this:
The solution is to upgrade classpath com.google.gms:google-services to classpath 'com.google.gms:google-services:3.2.1' in file in build.gradle Project:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.1'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
it works

error in creating new android studio project

Hi i recently ran into some problem related to creating new project in android studio. Whenever i create a new project in android studio project is not getting created properly even the structure is getting generated differently i dont what has happened you can see the images below to understand the problem.
This has started happening when i faced this problem so it was suggested that i remove .gradle file and after that i'm not able to create new project.
EDIT my grdle file
// 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.0.1'
// 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
}

Error:Configuration with name 'default' not found when building for Sony Smart Glass

I am trying to develop an app for Sony Smart Glass in Android Studio 2.1.2. I tried to add the Sony Smart Glass sample library functions. I am getting an error like that
Error:Configuration with name 'default' not found.
My settings.gradle:
include ':app'
include ':libraries:mylib'
My build.gradle:
// 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'
// 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
}
The best starting place to create a SmartEyeglass app is with one of the samples. They already have all of the necessary dependencies declared for you. As a basic example try starting with the "HelloWorld" sample. In the end though your settings.gradle file should include this:
includeFlat 'SmartExtensionAPI'
includeFlat 'SmartExtensionUtils'
includeFlat 'SmartEyeglassAPI'
And your build.gradle file should include this
compile project(':SmartEyeglassAPI')
compile project(':SmartExtensionAPI')
compile project(':SmartExtensionUtils')
Please let me know if that helps.

Categories