Error with Android Studio while using Facebook Audience Network - android

I have tried to put Facebook ads in my application, which is earlier works with Google Admob ads. But while adding this line in my gradle file makes errors. compile 'com.facebook.android:audience-network-sdk:4.+'. I have also tried with the specified versions. But same errors.
Main error is
can't resolve Symbol R
I also tried clean, rebuild and Sync Project with Gradle file. But no response.
I have updated my Google play services, and Google Respirotory.
Here is my build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 15
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.myapp.application"
minSdkVersion 15
targetSdkVersion 15
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':businessApp')
compile 'com.facebook.android:audience-network-sdk:4.+'
}
I can successfully build the gradle if I remove this line
compile 'com.facebook.android:audience-network-sdk:4.+'
There is no other errors in My app. If I need to change anything in Android studio to use Facebook Audience Network, or any other requirements?

After adding this dependency , sync your project and then click on Build-->Clean Project

Related

Cannot build Google Development Project

I am able to successfully test on my android device via "Build and Run" in Unity 5.3.5.
I am able to export the unity project to Android Studio.
However, when I run the android studio project, it gives me numerous errors.
The first was solved by adding the following to the .gradle file:
multiDexEnabled true
Now I have come across the problem of:
Error:Execution failed for task ':fishDiver:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/unity/purchasing/amazon/BuildConfig.class
My gradle file is as such:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.sink.fish"
minSdkVersion 9
targetSdkVersion 19
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':amazonAppStore')
compile project(':googleAIDL')
compile project(':googlePlay')
compile project(':common')
compile project(':unityadsrelease')
compile files('libs/unity-classes.jar')
}
Can anyone point me in the right direction?
I have not added anything extra, only the Unity Ads API, Unity IAP API, and the Unity Analytics API.
But other then that it is a pretty basic build and it is not working!
What I have tried:
gradle cleaning:
./gradlew clean
Deleting the build folders,
removing any added plugins for Android within Unity,
Rebuilding and cleaning from within Android Studio
random tweaks here and there

Android studio 1.2.2 fails to import library

I have the following bulid.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.onlinecomments.android"
minSdkVersion 14
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
//The below is the one that is failing
compile 'com.github.rahatarmanahmed:circularprogressview:2.3.2'
}
I did the "Sync Now" that shows on the page and I did "Tools -> Android -> Sync Project With Gradle Files" and both failed to import the library, so when I do "Alt + Enter" on the below I don't get the "Import class"
CircularProgressView cpb;
So what I did next is that I created a test android project and the import was successful, anyone had this issue and made it work?
Please note that the program compiles just fine without the last library I noted above.
Situations like this I make the following, then look for an answer :-) :
Make sure gradle is not set to work offline.
Clean & Build.
Remove then re-add the dependency.
Also if it's like you said that it works in another project, your last resort is to make a new project and re-add the sources.

Unable to build project in Android Studio

I imported a project into Android Studio from Eclipse. It was building successfully in Eclipse.
At the end of importing process I got this error:
Gradle project sync failed. Basic functionality will not work
In the Gradle console I get the following error:
Error:Failed to find: com.android.support:appcompat-v7:20.+
I have already installed google support repository as mentioned in other places.
This is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "21.0.0"
defaultConfig {
applicationId "com.entujn.demo"
minSdkVersion 10
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:+'
compile 'com.android.support:appcompat-v7:20.+'
compile files('libs/commons-lang3-3.3.2.jar')
}
local.properties:
sdk.dir=/home/pankaj/adt-bundle-linux-x86_64-20140702/sdk
SDK directory structure screenshot
Looks like the appcompat stuff is not present at the right place, how do I fix it ?
Looks like Android Studio uses another copy of SDK, which does not have Android Support repository installed. Please make sure it has all needed components installed.

Android Studio project unable to find com.google.android

I have two Android Studio projects using Google Maps. One works fine, the other is unable to find com.google.android and so can't compile. Fails with
error: package com.google.android.gms.maps.model does not exist
Both have the same code in Manifest.xml
<meta-data
android:name="com.google.android.gms.version"
android:value="4323000" />
Both have the same import statement.
build.gradle is:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 11
targetSdkVersion 19
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:+'
compile 'com.android.support:appcompat-v7:+'
}
I've read several similar questions on StackOverflow but those answers have no beneficial effect.
Any thoughts appreciated ...
Please add Google Play services to your project..
Google Play Services Rev 16 was added via SDK Manager, but it seems you have to manually add it via Project/Structure as a Dependency also. (You didn't do that on the project that was working already, but it does show up there, so somehow it added automatically in that case) So kindly add that manually..
Add this to dependencies:
compile 'com.google.android.gms:play-services:4.3.23'
And replace (or leave) 4.3.23 with version you need, i.e. 4.3.+

Android Studio and Getting Maps Correctly installed

I am new to Android Studio, but I currently get this error:
error: package com.google.android.gms.maps does not exist
Now, if I in
project/module/build.gradle I do this
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 8
targetSdkVersion 17
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
} }
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile files('src/main/libs/google-play-services.jar') }
I currently get this error:
Could not find method
android.webkit.WebView.setWebContentsDebuggingEnabled
And earlier I got this
Could not find class 'com.google.android.gms.maps.SupportMapFragment'
Whatt is the correct thing to do here / how do I solve above errors?
For reference: I orignally manually converted this project form a broken Eclipse project - sadly, for both Eclipse builds and Android Studio builds, it is the map/library thing that I seem unable o solve. The app is otherwise still working as it was before.
Replace
compile files('src/main/libs/google-play-services.jar')
with
compile 'com.google.android.gms:play-services:4.0.30'
or use newer version if you want.
You need to have Google Play Services downloaded in SDK.

Categories

Resources