missing manifest when using plugin in android studio - android-studio

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'
}
}
}

Related

Android Studio doesn't parse/recognize java files

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'

Could not find method implementation() for arguments on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

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

Error:(22, 0) Could not find method android() for arguments

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`

Android NDK gradle setting

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")
}

Issue with running a gradle project on android

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.

Resources