Android Studio doesnt recognize my device - LG Spirit 4G - android

I have developer options enabled, the driver is updated(says the OS win10), and I followed the instructions of the documentation. My manifest :
<application
android:debuggable="true" //this line says it shouldnt be harcoded?
android:allowBackup="true"
android:icon="#drawable/ic_piano"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
And the build graddle file:
android {
// 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.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
}
android {
buildTypes {
debug {
debuggable true
}
Both manifest and build code copied from the documentation. But it fails to build.graddle. It says: expectin '}' found "
I dont know what is this suposed to mean, since i've done everything the documentation says. I've serached all the answers here in SO but haven't any that worked...Any ideias?
The link: https://developer.android.com/studio/run/device.html

You have messed up your build.gradle, it should look like this:
// 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.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
}
Note that this is your top level build.gradle, it will sit in the root directory of your project. There should another build.gradle inside of a folder likely called /app this is the file where you add and amend the android{} gradle clojure

Related

Gradle Fails to implement com.mapbox.maps:android:10.2.0

I need to import import com.mapbox.maps.plugin.annotation.generated.PointAnnotationOptions; in my app code, for that I need to implement com.mapbox.maps:android:10.2.0 in build.gradle module, but it fails.
Could someone tell me, why this gradle implement fails to resolve?
implementation ('com.mapbox.maps:android:10.2.0'){
exclude group: 'group_name', module: 'module_name'
}
This is the error msg:
Failed to resolve: com.mapbox.maps:android:10.2.0
In stack trace it says: NotFound com.mapbox.maps:android:10.2.0
Show in Project Structure dialog
Affected Modules: app
build.gradle (project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication{
basic(BasicAuthentication)
}
credentials{
username='mapbox'
password= project.properties['MAPBOX_DOWNLOADS_TOKEN'] ?:""
}
}
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ERROR INFORMATION
After a a few hours of research I came to find out how to properly set up Mapbox (10.0.2) on Android
IMO, this first bullet should solve the issue, otherwise keep going.
First, in settings.gradle -> as stated previously set mode to PREFERS.SETTINGS .
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
credentials {
// Do not change the username below.
// This should always be `mapbox` (not your username).
username = "mapbox"
// Use the secret token you stored in gradle.properties as the password
password = MAPBOX_DOWNLOADS_TOKEN
}
}
}
}
Second, add the dependency as per usual to module-level build.gradle (not project level)
implementation 'com.mapbox.maps:android:10.2.0'
Third, this is what my project-level build.gradle looks like.
buildscript {
ext {
compose_version = '1.2.0-alpha02'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Last, in your gradle.property make sure you have
(GOOD) MAPBOX_DOWNLOADS_TOKEN = SECRET_ACCESS_CODE
(DO NOT) MAPBOX_DOWNLOADS_TOKEN = "SECRET_ACCESS_CODE"

android build gradle error (android 3.1.3)

I reinstalled my android studio and thereafter i am getting error while building gradle.
I did every change that can help in building gradle but then also it showed error as "configure build" error.
so kindly help me so that i can start my android programming.
gradle version - 4.4
android plugin version - 3.1.3`
i have changed google() to maven() but nothing happened.
//build.gradle file
// Top-level build file where you can add configuration options common to all
sub-projects/modules.
buildscript {
repositories {
google()
jcenter { url 'http://jcenter.bintray.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// 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
}

Android Studio importing Jetbrains Exposed

I am new to Android development. I have created a new project with Android Studio and need to import jetbrains exposed library into my existing project. When I tried to follow the exposed Getting Started guide to add the following into the build.grade file:
repositories {
maven {
url "https://dl.bintray.com/kotlin/exposed"
}
}
dependencies {
compile 'org.jetbrains.exposed:exposed:0.10.2'
}
I get the following error:
Could not find method compile() for arguments [org.jetbrains.exposed:exposed:0.10.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
I have been searching the internet for a couple of days now but still could not find out what's the problem.
This is the build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.40'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
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()
}
}
repositories {
maven {
url "https://dl.bintray.com/kotlin/exposed"
}
}
dependencies {
compile 'org.jetbrains.exposed:exposed:0.10.2'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Hopefully someone could help me.
Thanking in advance.
You should put this dependency in the module level build.gradle file - by default, this is in the app folder, as opposed to the project level build.gradle file, which is in the root of your project.
Also, you should use implementation instead of compile, since you're using a newer than 3.0 version of the Android Gradle plugin:
repositories {
maven {
url "https://dl.bintray.com/kotlin/exposed"
}
}
dependencies {
implementation 'org.jetbrains.exposed:exposed:0.10.2'
}

I am not able to sync my android project as it was build on another PC. How to solve it?

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript [poiu{
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.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
}
buildscript **[poiu**{
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
Pay attention to the code wrapped in * - the code there should be purely buildscript without the [poui at all.
As to how this happened; It might be copy-paste error(paste in wrong place) or it might be accidental code writing. The point is to fix it. Gradle build errors are not as detailed and the IDE does not show error in the same way the java(or C++ etc) compilers and IDE's show them.

Error:Could not find com.android.tools.build:gradle:2.1.0-alpha1

I update my android studio and restart it, it works properly but when i try to imoprt my previous project it shows error somthing like that:
here is the snapshot of error...
Error during import the project
and here is my gradle file...
// 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.0-alpha1'
// 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
}
Try with other distribution of gradle.
Open gradle-wrapper.propertieswhich It's inside gradle/wrapper folder and in distributionUrl set another one which work, for example:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
EDIT
Try with this classpath in global build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
I had the same problem upgrading my Android Studio to 2.2.0. I changed the classpath property of my build.gradle file but the difference with the answers above is that I didn't put the version of the Gradle but the Android Studio's one and it worked. Note that you also need to verify the Ggradle home path in file>>settings>>build,execution,deployment>>gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.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
I had this problem today, and when I updated the Android Plugin Version to the recent one, it worked. So, I think when you meet this problem, you can update the Gradle and Android Plugin Version to the newest. It always works. This is my configuration:

Categories

Resources