I have a very weird problem with Android Studio Chipmunk. It doesn't recognize java syntax and all IDE features are disabled, like autocomplete, autoimports, etc., but only in one of my projects. If I open other projects It works good, but with one of them It doesn't work. It's like the project were only c++, because if I try to create a new class (right button -> New), only "c++ class" is shown, and "java class" option is missing.
I have tried all answers I have found in stackoverflow but without success:
Invalidate caches and restart
Clean, rebuild, make.
Check Power save mode is unchecked.
Delete .idea folders, and other folders like .gradle, etc.
Rename some folders in users//appdata/local...android
File -> sync project with gradle files
Update all dependencies in gradle file to latest versions.
Check gradle-wrapper.properties
I don't know what else I could do. This is my build.gradle, but ask me for another file if it were required.
buildscript {
repositories {
google()
mavenCentral()
jcenter()
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.google.gms:google-services:4.3.13'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.1'
}
}
apply plugin: 'com.android.application'
repositories{
mavenCentral()
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://maven.google.com" } // <<<< REPOSITORY HERE
maven { url 'https://maven.fabric.io/public' }
}
}
apply plugin: 'com.android.application'
dependencies {
implementation 'com.google.firebase:firebase-crashlytics:18.2.13'
implementation 'com.google.firebase:firebase-analytics:21.1.1'
implementation 'com.google.firebase:firebase-messaging:23.0.8'
implementation files('libs/ZSDK_ANDROID_API.jar')
implementation files('libs/ZSDK_ANDROID_BTLE.jar')
def acraVersion = '5.9.6'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.jpardogo.materialtabstrip:library:1.1.1'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.github.shell-software:fab:1.1.2'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.daimajia.swipelayout:library:1.2.0#aar'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.rey5137:material:1.3.1'
implementation 'com.chauthai.swipereveallayout:swipe-reveal-layout:1.4.1'
implementation 'com.google.android.gms:play-services-vision:20.1.3'
implementation 'androidx.mediarouter:mediarouter:1.3.1'
implementation 'androidx.appcompat:appcompat:1.5.0'
implementation 'com.google.firebase:firebase-core:21.1.1'
implementation "androidx.viewpager:viewpager:1.0.0"
// this line must be included to use FCM
implementation 'androidx.multidex:multidex:2.0.1'
// ACRA
implementation "ch.acra:acra-mail:$acraVersion"
implementation "ch.acra:acra-dialog:$acraVersion"
// Debug implementation base de datos
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'
}
android {
compileSdkVersion 33
buildToolsVersion '33.0.0'
defaultConfig {
applicationId "com.mycompany.myproject"
targetSdkVersion 33
minSdkVersion 19
setProperty("archivesBaseName", "myproject")
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
compileOptions.encoding "ISO-8859-1" // For Spanish [Otherwise strange accents]
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
// Specifies a flavor dimension.
flavorDimensions "color"
productFlavors {
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
androidTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildTypes {
release {
debuggable false
minifyEnabled true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
}
}
productFlavors {
defaultFlavor {
proguardFile 'proguard-rules.txt'
}
}
signingConfigs {
release {
v2SigningEnabled false
}
}
android {
lintOptions {
abortOnError false
}
}
packagingOptions {
resources {
excludes += ['META-INF/LICENSE.txt', 'META-INF/NOTICE.txt', 'META-INF/NOTICE', 'META-INF/LICENSE', 'META-INF/DEPENDENCIES']
}
}
ndkVersion '25.1.8937393'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
Related
I searched a lot on the web, but couldn't find a solution. I have a a project named VolleyLib with a library module named volleylib. I'm trying to publish the library on mavenLocal repo, but when build the project no publishing task is executed (only prepareLintJarForPublish). And of course nothing goes into .m2 folder (which I created myself after installed maven...). I can't really get why and what is wrong. Probably something's missing...
Here's my build.gradle for volleylib module:
plugins {
id 'com.android.library'
id 'maven-publish'
}
android {
compileSdk 31
defaultConfig {
minSdk 22
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.android.volley:volley:1.2.1'
implementation 'com.fasterxml.jackson.jr:jackson-jr-annotation-support:2.13.1'
implementation 'androidx.room:room-common:2.4.1'
annotationProcessor 'androidx.room:room-compiler:2.4.1'
implementation 'androidx.room:room-coroutines:2.1.0-alpha04'
implementation 'androidx.room:room-runtime:2.4.1'
implementation 'androidx.room:room-migration:2.4.1'
implementation 'androidx.room:room-rxjava2:2.4.1'
}
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
release(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = 'com.example.VolleyLib'
artifactId = 'final'
version = '1.0'
}
// Creates a Maven publication called “debug”.
debug(MavenPublication) {
// Applies the component for the debug build variant.
from components.debug
groupId = 'com.example.VolleyLib'
artifactId = 'final-debug'
version = '1.0'
}
}
repositories {
mavenLocal()
}
}
}
Any help would be greatly appreciated.
It's the first time I try this, so apologize if it's a trivial question...
Thank you all in advance.
My working library build.gradle is almost like yours. Except, it doesn't use the following:
plugins {
id 'com.android.library'
id 'maven-publish'
}
but the following:
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
And I'm using Java 8 for compileOptions block:
android {
...
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
And, lastly, without repositories in afterEvaluate:
afterEvaluate {
publishing {
...
// Remove the following commented line:
// repositories {
// mavenLocal()
// }
}
}
Then, to build and install the library to maven local, click gradle icon on the left menu of Android Studio. Then select projectName -> libraryName -> Run Configuration -> publishToMavenLocal.
UPDATE:
Here the complete build.gradle.
root build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.1'
}
}
repositories {
mavenCentral()
}
allprojects {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven { url "https://jitpack.io" }
google()
}
}
ext {
compileSdkVersion = 31
buildToolsVersion = '30.0.2'
minSdkVersion = 16
targetSdkVersion = 31
junitVersion = '4.13.2'
androidxAppcompatVersion = '1.4.1'
androidApplicationId = 'com.project.sample'
androidVersionCode = 1000
androidVersionName = "1.0.0"
androidAppName = 'Sample'
}
my library build.gradle (jcplayer library in root/jcplayer directory):
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation "androidx.appcompat:appcompat:$androidxAppcompatVersion"
}
// Because the components are created only during the afterEvaluate phase, you must
// configure your publications using the afterEvaluate() lifecycle method.
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
jcplayer(MavenPublication) {
// Applies the component for the release build variant.
from components.release
// You can then customize attributes of the publication as shown below.
groupId = rootProject.ext.androidApplicationId
artifactId = 'jcplayer'
version = rootProject.ext.androidVersionName
}
}
}
}
I'm using Android Studio and I'm trying to integrate FireBase in my application. For that, I need to add dependencies in both project's root build.gradle and module's build.gradle. But I understand that there's only one build.gradle in my project. When I added everything (dependencies for FireBase) in the same build.gradle, it wasn't working.
So I understood it has something to do with build.gradle.
Here's the project structure screenshot .Probably the project was imported from eclipse. Is there any way I can have 2 build.gradle files without creating the project again?
This post has similarity with Android Project Structure is incorrect; only one build.gradle. Please dont mark it as duplicate. Because in the above link, the answer was to go with a single build.gradle. But in my case I need 2 build.gradle to proceed further. Since I don't have enough reputation, i couldn't comment on that post. Sorry.Please help.
here's how my only build.gradle looks like :
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
//FireBase dependency
//classpath 'com.google.gms:google-services:3.0.0'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
//FireBase dependency
compile 'com.google.firebase:firebase-messaging:9.6.1'
compile 'com.google.firebase:firebase-core:9.6.1'
}
//FireBase
//apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 21
buildToolsVersion '23.0.3'
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
productFlavors {
x86 {
ndk {
abiFilter "x86"
}
}
arm {
ndk {
abiFilters "armeabi-v7a", "armeabi"
}
minSdkVersion 19
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/license.txt'
exclude 'META-INF/notice.txt'
}
defaultConfig {
minSdkVersion 19
applicationId "com.nytshift.eym.pas"
}
}
You have two gradles. You need to change the view of the filesystem from the top left. Change it to "android"
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.