Mopub Banner ads is not appearing - android

I am kind of newbie in Android Programming, So I Just want to Display Mopub banner ad in my app. I created the Sample app, also created Ad unit id in Mopub.
I successfully integrated SDK and following their https://developers.mopub.com/docs/android/banner/ instructions on this page.
but I don't know why my app which is Live on G-play Only sending the request but no impression. I also checked on my Phone & its true. No ads are displaying. Here is My Code
Can anyone Help me Please?
mainactivity.java:-
import com.mopub.mobileads.MoPubErrorCode;
import com.mopub.mobileads.MoPubView;
import static com.mopub.mobileads.MoPubView.BannerAdListener;
public class MainActivity extends AppCompatActivity implements BannerAdListener {
private MoPubView mBanner;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mBanner = (MoPubView) findViewById(R.id.bannerview);
mBanner.setAdUnitId("XXXXXXXXXXXXXXXXXXXXXXXX"); // Enter your Ad Unit ID from www.mopub.com
mBanner.setBannerAdListener(this);
mBanner.loadAd();
}
#Override
protected void onDestroy() {
mBanner.destroy();
super.onDestroy();
}
#Override
public void onBannerLoaded(MoPubView banner) {
Log.d("MoPub Demo", "Banner loaded callback.");
}
#Override
public void onBannerFailed(MoPubView banner, MoPubErrorCode errorCode) {
Log.d("MoPub Demo", "Banner failed callback with: " + errorCode.toString());
}
#Override
public void onBannerClicked(MoPubView banner) {
Log.d("MoPub Demo", "Banner clicked callback.");
}
#Override
public void onBannerExpanded(MoPubView banner) {
Log.d("MoPub Demo", "Banner expanded callback.");
}
#Override
public void onBannerCollapsed(MoPubView banner) {
Log.d("MoPub Demo", "Banner collapsed callback.");
}
}
Activity_main.xml:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.mopub.mobileads.MoPubView
android:id="#+id/bannerview"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
Build.gradle(module.app):-
repositories {
// ... other project repositories
jcenter() // includes the MoPub SDK and AVID library
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.your.prject.appmopubtest"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation('com.mopub:mopub-sdk:4.20.0#aar') {
transitive = true
}
}
Build.gradle(project.appmopubtest):-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
// 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
}
androidmanifest.xml:-
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.your.prject.appmopubtest">
<!-- Required permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Optional permissions. Will pass Lat/Lon values when available. Choose either Coarse or Fine -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- All ad formats -->
<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
<!-- Interstitials -->
<activity android:name="com.mopub.mobileads.MoPubActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<!-- Rewarded Video and Rewarded Playables -->
<activity android:name="com.mopub.mobileads.RewardedMraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
</application>
</manifest>

Related

Banner Ad load failed with test Ad ID on admob android

I was trying to add Admob's Banner ad with test UnitId in my app. But it doesn't load on my app. it comes up with Toast message "Ad load failed!" that I added into onAdFailedToLoad().
Here are my codes :
MainActivity.Java
public class MainActivity extends AppCompatActivity {
private AdView mAdView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
MobileAds.initialize(this, "ca-app-pub-3940256099942544~3347511713");
mAdView = findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build() ;
mAdView.loadAd(adRequest);
mAdView.setAdListener(new AdListener() {
#Override
public void onAdLoaded() {
// Code to be executed when an ad finishes loading.
Toast.makeText(MainActivity.this, "Ad loaded successfully!", Toast.LENGTH_SHORT).show();
}
#Override
public void onAdFailedToLoad(int errorCode) {
// Code to be executed when an ad request fails.
Toast.makeText(MainActivity.this, "Ad load failed!", Toast.LENGTH_SHORT).show();
// mAdView.setVisibility(View.GONE);
}
#Override
public void onAdOpened() {
// Code to be executed when an ad opens an overlay that
// covers the screen.
Toast.makeText(MainActivity.this, "Ad opens an overlay that covers the screen", Toast.LENGTH_SHORT).show();
}
#Override
public void onAdLeftApplication() {
// Code to be executed when the user has left the app.
Toast.makeText(MainActivity.this, "User left the app", Toast.LENGTH_SHORT).show();
}
#Override
public void onAdClosed() {
// Code to be executed when the user is about to return
// to the app after tapping on an ad.
Toast.makeText(MainActivity.this, "Ad viewed by user!", Toast.LENGTH_SHORT).show();
}
});
Here's activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/appbar_padding_top"
android:theme="#style/AppTheme">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="wrap_content"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="center"
android:layout_weight="5"
android:background="?attr/colorPrimary"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme"
app:title="#string/app_name">
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TabItem
android:id="#+id/tabItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tab_text_1" />
<android.support.design.widget.TabItem
android:id="#+id/tabItem2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tab_text_2" />
<android.support.design.widget.TabItem
android:id="#+id/tabItem3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tab_text_3" />
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/AdMob_ID"/>
</android.support.design.widget.CoordinatorLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.a3dwallpaper2018">
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/AdMob_ID"/>
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="#android:style/Theme.Translucent" />
</application>
</manifest>
Build.gradle(Module:app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.a3dwallpaper2018"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
sourceSets {
main {
assets.srcDirs = ['src/main/assets', 'src/main/assets/']
res.srcDirs = ['src/main/res', 'src/main/res/drawable']
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-storage:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.mindorks:placeholderview:0.7.1'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation 'com.github.bumptech.glide:glide:4.2.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.android.support:palette-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0 '
implementation 'com.google.android.gms:play-services-ads:17.0.0'
implementation 'com.google.firebase:firebase-ads:17.0.0'
}
Build.gradle(Project: Project_Name)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I've tried so many solutions that I got from the google search but ultimately nothing works. I've found this possible error's from logcat.
One:
Unable to get advertising id: com.google.android.gms.common.GooglePlayServicesNotAvailableException: com.google.android.gms.measurement.internal.zzba.zzby
Two :
V/FA: Inactivity, disconnecting from the service
V/FA: onUnbind called for intent. action: com.google.android.gms.measurement.START
V/FA: Local AppMeasurementService is shutting down
Three :
W/GooglePlayServicesUtil: Google Play Store is missing.
E/FirebaseInstanceId: Google Play services missing or without correct permission.
I'm using real device to test my app and it has Google play services (Updated) & Google play store (Updated) both. I also tried with addTestDevice(My device id) , but it didn't helped.
Error 1 means the ID is wrong.
Admob gives you a number like this and is the app ID, with ~ :
ca-app-pub-9611919736642270~3440171884
And the unit id with / is to the request;
ca-app-pub-9611919736642270/3440171834
app id and unit id should be different. in your code seems to be same
here is full official description: https://firebase.google.com/docs/admob/android/quick-start
you have to get Unit Id from admob and use it in AdMob_ID

Google Play services error Execution failed for task ':transformClassesWithJarMergingForRelease'

Im trying to implement Google play services into my game. Also, im using AdInCube plugin., which works fine, but now i have two AndroidManifest files. Maybe thats the problem? I already fixed one error (https://github.com/playgameservices/play-games-plugin-for-unity/issues/2028) by reimporting package and force resolve. After this, i cant build my game. I got an error:
What went wrong:
Execution failed for task ':transformClassesWithJarMergingForRelease'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/auth/api/signin/
GoogleServices Manifest:
<?xml version="1.0" encoding="utf-8"?>
<!-- This file was automatically generated by the Google Play Games plugin for Unity
Do not edit. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.example.games.mainlibproj"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="14" />
<application>
<!-- The space in these forces it to be interpreted as a string vs. int -->
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="\u003402577249840" />
<!-- Keep track of which plugin is being used -->
<meta-data android:name="com.google.android.gms.games.unityVersion"
android:value="\u0030.9.53" />
<activity android:name="com.google.games.bridge.NativeBridgeActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
</application>
</manifest>
AdInCube Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.****.snake.101"
android:installLocation="preferExternal"
android:versionCode="9"
android:versionName="1.1.7">
<uses-permission android:name="com.android.vending.BILLING" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:icon="#drawable/app_icon"
android:label="#string/app_name"
android:theme="#style/UnityThemeSelector">
<activity
android:name="com.unity3d.player.UnityPlayerActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data
android:name="unityplayer.UnityActivity"
android:value="true" />
</activity>
</application>
</manifest>
Gradle:
buildscript {
repositories {
google()
maven {
url 'https://maven.google.com/'
name 'Google'
}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.application'
repositories {
maven {
url 'https://maven.google.com'
}
maven {
url 'http://repository.adincube.com/maven'
}
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.adincube.sdk:AdinCube-Unity-3626ebe:2.3.1#aar') {
transitive = true
}
compile 'com.android.support:multidex:1.0.1'
**DEPS**
}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
defaultConfig {
targetSdkVersion '28'
minSdkVersion 14
multiDexEnabled true
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress '.unity3d', '.ress', '.resource', '.obb'
}
**SIGN**
buildTypes {
debug {
minifyEnabled **MINIFY_DEBUG**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
jniDebuggable true
}
release {
minifyEnabled **MINIFY_RELEASE**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD**
**SIGNCONFIG**
}
}
packagingOptions {
exclude 'lib/armeabi/libadcolony.so'
exclude 'lib/armeabi/libjs.so'
exclude 'lib/arm64-v8a/libadcolony.so'
exclude 'lib/arm64-v8a/libjs.so'
exclude 'lib/x86_64/libadcolony.so'
exclude 'lib/x86_64/libjs.so'
}
}
dependencies {
compile ('com.adincube.sdk:AdinCube-Unity-3626ebe:2.+#aar') {
transitive = true
}
compile 'com.android.support:multidex:1.0.1'
}
repositories {
maven {
url 'https://maven.google.com'
}
maven {
url 'http://repository.adincube.com/maven'
}
jcenter()
}
android {
defaultConfig {
multiDexEnabled true
}
}
android {
packagingOptions {
exclude 'lib/armeabi/libadcolony.so'
exclude 'lib/armeabi/libjs.so'
exclude 'lib/arm64-v8a/libadcolony.so'
exclude 'lib/arm64-v8a/libjs.so'
exclude 'lib/x86_64/libadcolony.so'
exclude 'lib/x86_64/libjs.so'
}
}

I/CrashlyticsCore: Crashlytics report upload complete but not show in dashboard

I have problem with Fabric. its a test project for find problem and do everything step by step in fabric documents, but i don't know what is mistake. please help me.
My Gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.mycompany.testtt"
minSdkVersion 17
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile('com.crashlytics.sdk.android:crashlytics:2.9.4#aar') {
transitive = true;
}
}
My Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.testtt">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="io.fabric.ApiKey"
android:value="9fd0b323bad2f5dae063288c94fd3a2317faa104"
/>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Main Activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Fabric.with(this, new Crashlytics());
// TODO: Move this to where you establish a user session
logUser();
setContentView(R.layout.activity_main);
}
private void logUser() {
// TODO: Use the current user's information
// You can call any combination of these three methods
Crashlytics.setUserIdentifier("12345");
Crashlytics.setUserEmail("user#fabric.io");
Crashlytics.setUserName("Test User");
}
public void forceCrash(View view) {
throw new RuntimeException("This is a crash");
}
After all, and error and testing, but nothing is still displayed on the dashboard.
I do everything step by step from fabric documents.
I have this problem for a few days, and anyway I've tested it, but I still have not gotten a result and does not display anything in the fabric dashboard. ApiKey is correct and I'm sure of it.
(sorry for English)

Android + AndroidAnnotations REST API

I am trying to create a simple learning project with AndroidAnnotations, which will work with REST calls. I have followed this tutorial
https://github.com/androidannotations/androidannotations/wiki/Rest-API#rest
but with no luck. Project builds successfully, but at runtime, my #RestService is always null and I cannot get it to work.
Here is how my structure looks like:
build.gradle
apply plugin: 'com.android.application'
def AAVersion = '4.3.0'
dependencies {
annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile "org.androidannotations:rest-spring-api:$AAVersion"
compile 'com.fasterxml.jackson.core:jackson-core:2.7.2'
compile 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
}
Interface (separate file):
#Rest(rootUrl = "https://api.github.com", converters = {StringHttpMessageConverter.class})
public interface GithubClient {
#Get("/search/repositories?q={searchString}")
GitResult getResult(#Path String searchString);
}
MainActivity:
public class MainActivity extends AppCompatActivity {
#RestService
GithubClient restClient;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Click(R.id.btn_Request)
void requestCall(){
searchAsync();
}
#Background
void searchAsync(){
try {
GitResult result = restClient.getResult("angular");
} catch (RestClientException e){
Log.e("Rest error",e.toString());
}
}
}
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.com.githubbrowser">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity_">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Am I missing any package, or what am I doing wrong here? Any help or recommendations would be highly appreciated.
So the problem was that I was missing the following dependencies under build.gradle:
compile "org.androidannotations:rest-spring:$AAVersion"
compile 'com.fasterxml.jackson.core:jackson-databind:2.3.2'
Just to update this thread, currently compile is obsolete therefore I use this
// android annotation
implementation "org.androidannotations:androidannotations-api:4.5.2"
annotationProcessor "org.androidannotations:androidannotations:4.5.2"
implementation "org.androidannotations:rest-spring-api:4.5.2"
annotationProcessor "org.androidannotations:rest-spring:4.5.2"
implementation "com.fasterxml.jackson.core:jackson-core:2.9.7"
implementation "org.springframework.android:spring-android-rest-template:2.0.0.M3"

Firebase android facebook,google,email login interface does not popup

I've watched a tutorial on YouTube about how to integrate Firebase to android applications. Registered Firebase, add my facebook and app info, and add the necessary changes to my app but somehow my main interface which should show login screens does not show up. There is no build errors.
Here are my codes;
My build.gradle inside my app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.bogroup.ucuncuprogram"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
//compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.firebaseui:firebase-ui:0.4.4'
compile 'com.google.android.gms:play-services-auth:9.4.0'
compile 'com.android.support:animated-vector-drawable:25.0.0'
compile 'com.android.support:design:25.0.0'
compile 'com.android.support:support-v4:25.0.0'
compile 'com.android.support:cardview-v7:25.0.0'
compile 'com.android.support:customtabs:25.0.0'
compile 'com.android.support:recyclerview-v7:25.0.0'
//compile 'com.android.support:customtabs:25.2.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
My main java code:
package com.bogroup.ucuncuprogram;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import com.firebase.ui.auth.AuthUI;
import com.google.firebase.auth.FirebaseAuth;
public class MainActivity extends AppCompatActivity {
private static final int RC_SIGN_IN = 0;
EditText et;
private FirebaseAuth auth;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
auth = FirebaseAuth.getInstance();
if(auth.getCurrentUser() != null){
//USER ALREADY SIGNED IN
Log.d("AUTH", auth.getCurrentUser().getEmail());
}else{
startActivityForResult(AuthUI.getInstance()
.createSignInIntentBuilder()
.setProviders(AuthUI.FACEBOOK_PROVIDER,
AuthUI.EMAIL_PROVIDER,
AuthUI.GOOGLE_PROVIDER)
.build(),RC_SIGN_IN);
}
}
#Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode==RC_SIGN_IN){
if(resultCode==RESULT_OK){
//user logged in
Log.d("AUTH", auth.getCurrentUser().getEmail());
}else{
// user not authenticated
Log.d("AUTH", "NOT AUTHENTİCATED");
}
}
}
public void tikla(View v){
if (v.getId()==R.id.button){
Intent intent = new Intent(getApplicationContext(),ikinciekren.class);
CharSequence charlarim = et.getText();
intent.putExtra("anahtar",charlarim);
startActivity(intent);
//
}
/*
else if (v.getId()==R.id.button){
//
}
*/
}
}
My main build.gradle file (not under app)
// 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.2'
classpath 'com.google.gms:google-services:3.1.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
}
My android.manifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bogroup.ucuncuprogram">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ikinciekren">
<intent-filter>
<action android:name="android.intent.action.IKINCIEKREN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Also added google-services.json file under app and facebook id under in string.xml file
Any help is appreciated. Thanks in advance.
Try changing startActivityForResult() to:
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setProviders(Arrays.asList(
new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER).build(),
new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build(),
new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build()
))
.build(),
RC_SIGN_IN);
To learn more about authentication on Firebase UI library look at:
https://github.com/firebase/FirebaseUI-Android/tree/master/auth

Categories

Resources