error in creating new android studio project - java

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
}

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.5.2

ERROR: Could not find com.android.tools.build:gradle:3.5.2.
Searched in the following locations:
-
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom
-
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.jar
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.pom
- https://jcenter.bintray.com/com/android/tools/build/gradle/3.5.2/gradle-3.5.2.jar
Required by:
project :
Open File
ext {
var = '3.5.2'
var1 = '3.5.2'
}// 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.5.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
}
we recived this error from my android studio when run my projects
we used online and offline mod but they not worked corectly
This error has confused me
The following code is related to wrapper
ext {
var = '3.5.2'
var1 = '3.5.2'
}// 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.5.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
}
This problem basically occurs when you are trying to load an old project. The best solution as of my knowledge is to download the links one by one, the project is showing and sync it. Check out the build Gradle files for any outdated dependencies.
Check out if you have
google()
repo in your project. Make sure you find this line in your dependencies.
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
I also had this problem on Linux (ubuntu)
I tried different ways but the problem still didn't work out.
Finally, I remove /home/(user)/.gradle directory and restart Android Studio and this error fixed.
Follow these steps:
Copy paste the below code into Project level build.gradle 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.5.2'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Clean your project from Build > Clean Project
Rebuild you project from Build > Rebuild Project
Make Project from Build > Make Project
Then, File > Invalidate Caches/Restart

Android Studio <Failed to resolve: com.android.support:appcompat-v7:28.0.0>

i can't fix tihs problem Failed to resolve: com.android.support:appcompat-v7:28.0.0
anybody can fix this problem?
My problem
buid.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
maven {
url 'https://maven.google.com/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
First, check your build.gradle(Project), whether it was looking like below or not
Second, check your build.gradle(Module:app), whether it was looking like below or not
Please let me know, whether your issue has been resolved or not

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

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.

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