Why Android Volley library is unable to connect asp.net web api? - android

I am trying to call asp.net web api from Android Client using Volley library. The .net API is working fine and listening ports are:
http://localhost:5000 and https://localhost:5001 in my local machine.
But,When, I try to run android client keeping the base url as http://10.0.2.2:5000/api/login
I found below error in console->
04/23 23:13:41: Launching 'app' on Nexus 6 API 24.
Install successfully finished in 9 s 435 ms.
$ adb shell am start -n "com.example.tourexpwip/com.example.tourexpwip.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 3662 on device 'Nexus_6_API_24 [emulator-5554]'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/art: Late-enabling -Xcheck:jni
W/art: Unexpected CPU variant for X86 using defaults: x86
W/System: ClassLoader referenced unknown path: /data/app/com.example.tourexpwip-1/lib/x86
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter androidx.vectordrawable.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
I/System.out: URL: http://10.0.2.2:5000/api/login/
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
D/: HostConnection::get() New Host Connection established 0xa67ec7c0, tid 3662
E/Volley: [210] NetworkUtility.shouldRetryException: Unexpected response code 307 for http://10.0.2.2:5000/api/login/
D/: HostConnection::get() New Host Connection established 0xa67ecac0, tid 3683
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/OpenGLRenderer: Swap behavior 0
D/EGL_emulation: eglCreateContext: 0xb5c05660: maj 2 min 0 rcv 2
D/EGL_emulation: eglMakeCurrent: 0xb5c05660: ver 2 0 (tinfo 0xb5c032b0)
W/System.err: com.android.volley.ServerError
at com.android.volley.toolbox.NetworkUtility.shouldRetryException(NetworkUtility.java:201)
W/System.err: at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:145)
at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:132)
W/System.err: at com.android.volley.NetworkDispatcher.processRequest(NetworkDispatcher.java:111)
at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:90)
I/Choreographer: Skipped 68 frames! The application may be doing too much work on its main thread.
D/EGL_emulation: eglMakeCurrent: 0xb5c05660: ver 2 0 (tinfo 0xb5c032b0)
I/Choreographer: Skipped 35 frames! The application may be doing too much work on its main thread.
The controller class for login in ASP.NET web api->
namespace TourExpWIP1.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class LoginController : ControllerBase
{
NetCoreAuthenticationContext dbContext = new NetCoreAuthenticationContext();
public string Post([FromBody] TblUser value)
{
if (dbContext.TblUser.Any(user => user.UserName.Equals(value.UserName)))
{
TblUser user = dbContext.TblUser.Where(u => u.UserName.Equals(value.UserName)).First();
var client_post_hash_password = Convert.ToBase64String(
Common.SaltHashPassword(
Encoding.ASCII.GetBytes(value.Password),
Convert.FromBase64String(user.Salt)));
if (client_post_hash_password.Equals(user.Password))
return JsonConvert.SerializeObject(user);
else return JsonConvert.SerializeObject("Wrong Password");
}
else
{
return JsonConvert.SerializeObject("user does not exists in db");
}
}
}
}

Try this
1.In Android Manifiest, in tag application add:
inside tag application add this tag:
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<application
android:usesCleartextTraffic="true"
android:networkSecurityConfig="#xml/network_security_config"
...
/>
2.With a corresponding network_security_config.xml in app/src/main/res/xml/:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
More details please find from here- Link

Related

App crashes in the android studio emulator in maps activity

I have created a google map activity in android studio. I have also generated an api key from the link given and placed it in the appropriate place. But when I run the app it crashes without displaying anything. Here is the logcat
2018-12-19 16:13:00.080 17295-17295/? I/ik7.locationap: Not late-enabling -Xcheck:jni (already on)
2018-12-19 16:13:00.312 17295-17295/? W/ik7.locationap: Unexpected CPU variant for X86 using defaults: x86
2018-12-19 16:13:00.667 17295-17295/com.example.nik7.locationapp W/ik7.locationap: JIT profile information will not be recorded: profile file does not exits.
2018-12-19 16:13:00.669 17295-17295/com.example.nik7.locationapp I/chatty: uid=10087(com.example.nik7.locationapp) identical 10 lines
2018-12-19 16:13:00.670 17295-17295/com.example.nik7.locationapp W/ik7.locationap: JIT profile information will not be recorded: profile file does not exits.
2018-12-19 16:13:00.733 17295-17295/com.example.nik7.locationapp I/InstantRun: starting instant run server: is main process
2018-12-19 16:13:01.001 17295-17295/com.example.nik7.locationapp I/zzbz: Making Creator dynamically
2018-12-19 16:13:01.022 17295-17295/com.example.nik7.locationapp W/ik7.locationap: Unsupported class loader
2018-12-19 16:13:01.023 17295-17295/com.example.nik7.locationapp W/ik7.locationap: Skipping duplicate class check due to unsupported classloader
2018-12-19 16:13:01.033 17295-17295/com.example.nik7.locationapp I/DynamiteModule: Considering local module com.google.android.gms.maps_dynamite:0 and remote module com.google.android.gms.maps_dynamite:221
2018-12-19 16:13:01.033 17295-17295/com.example.nik7.locationapp I/DynamiteModule: Selected remote version of com.google.android.gms.maps_dynamite, version >= 221
2018-12-19 16:13:01.033 17295-17295/com.example.nik7.locationapp V/DynamiteModule: Dynamite loader version >= 2, using loadModule2NoCrashUtils
2018-12-19 16:13:01.113 17295-17295/com.example.nik7.locationapp W/ik7.locationap: Unsupported class loader
2018-12-19 16:13:01.131 17295-17295/com.example.nik7.locationapp W/ik7.locationap: Skipping duplicate class check due to unsupported classloader
2018-12-19 16:13:01.180 17295-17295/com.example.nik7.locationapp I/Google Maps Android API: Google Play services client version: 12451000
2018-12-19 16:13:01.192 17295-17295/com.example.nik7.locationapp I/Google Maps Android API: Google Play services package version: 14799040
2018-12-19 16:13:01.319 17295-17295/com.example.nik7.locationapp W/ik7.locationap: Accessing hidden field Ljava/nio/Buffer;->address:J (light greylist, reflection)
2018-12-19 16:13:01.712 17295-17295/com.example.nik7.locationapp D/OpenGLRenderer: HWUI GL Pipeline
2018-12-19 16:13:01.877 17295-17341/com.example.nik7.locationapp I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
2018-12-19 16:13:01.878 17295-17341/com.example.nik7.locationapp I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0
2018-12-19 16:13:01.878 17295-17341/com.example.nik7.locationapp I/OpenGLRenderer: Initialized EGL, version 1.4
2018-12-19 16:13:01.878 17295-17341/com.example.nik7.locationapp D/OpenGLRenderer: Swap behavior 1
2018-12-19 16:13:01.883 17295-17341/com.example.nik7.locationapp W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
2018-12-19 16:13:01.883 17295-17341/com.example.nik7.locationapp D/OpenGLRenderer: Swap behavior 0
2018-12-19 16:13:01.907 17295-17341/com.example.nik7.locationapp D/EGL_emulation: eglCreateContext: 0xe8310280: maj 2 min 0 rcv 2
2018-12-19 16:13:01.913 17295-17341/com.example.nik7.locationapp D/EGL_emulation: eglMakeCurrent: 0xe8310280: ver 2 0 (tinfo 0xe7093fa0)
2018-12-19 16:13:02.025 17295-17341/com.example.nik7.locationapp D/EGL_emulation: eglMakeCurrent: 0xe8310280: ver 2 0 (tinfo 0xe7093fa0)
2018-12-19 16:13:02.034 17295-17338/com.example.nik7.locationapp D/EGL_emulation: eglCreateContext: 0xe9d05f00: maj 1 min 0 rcv 1
2018-12-19 16:13:02.229 17295-17338/com.example.nik7.locationapp D/EGL_emulation: eglMakeCurrent: 0xe9d05f00: ver 1 0 (tinfo 0xe9d03470)
2018-12-19 16:13:02.564 17295-17319/com.example.nik7.locationapp D/NetworkSecurityConfig: No Network Security Config specified, using platform default
2018-12-19 16:13:03.305 17295-17319/com.example.nik7.locationapp E/AndroidRuntime: FATAL EXCEPTION: Thread-6
Process: com.example.nik7.locationapp, PID: 17295
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/ProtocolVersion;
at ez.b(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):3)
at ey.a(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):3)
at fa.a(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):15)
at com.google.maps.api.android.lib6.drd.al.a(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):6)
at ed.a(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):21)
at ed.run(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):8)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.ProtocolVersion" on path: DexPathList[[zip file "/data/user_de/0/com.google.android.gms/app_chimera/m/00000015/MapsDynamite.apk"],nativeLibraryDirectories=[/data/user_de/0/com.google.android.gms/app_chimera/m/00000015/MapsDynamite.apk!/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at ad.loadClass(:com.google.android.gms.dynamite_dynamiteloader#14799084#14.7.99 (100700-223214910):4)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at ez.b(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):3) 
at ey.a(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):3) 
at fa.a(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):15) 
at com.google.maps.api.android.lib6.drd.al.a(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):6) 
at ed.a(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):21) 
at ed.run(:com.google.android.gms.dynamite_mapsdynamite#14799084#14.7.99 (100700-223214910):8) 
2018-12-19 16:13:03.338 17295-17295/com.example.nik7.locationapp E/SchedPolicy: set_timerslack_ns write failed: Operation not permitted
2018-12-19 16:13:03.379 17295-17319/com.example.nik7.locationapp I/Process: Sending signal. PID: 17295 SIG: 9
This is the compelte log.I have even tried by removing the restrictions but that didn't work. Whats the issue here. I have also seledted api 23 marshmallow. I have done nothing except entering the api key in its place
EDIT: I also included the key in the manifest but still the app is crashing
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="YOUR_API_KEY"/>
EDIT:
Seems to be an issue in API 28
To fix it add this code under application in your manifest file:
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
Its probably because you dont have google play services installed. If you ran the app on your actual phone it would work just fine.
To fix it, you either add this line of code inside the in the manifest
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
Or
to upgrade your play-services-maps in build.gradle to
implementation 'com.google.android.gms:play-services-maps:16.1.0'
That worked for me

Facebook Audience Network not displaying test Ads. Already added TestDevice

I created a new sample project for displaying the Facebook audience network Banner ad at bottom of my activity.
My app is running in device but not displaying anything at bottom. I already added the hash for test device.
MainActivity.java
package liveradio.radioz.com.facebookads;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.facebook.ads.*;
import android.widget.LinearLayout;
public class MainActivity extends AppCompatActivity {
private AdView adView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
adView = new AdView(this, "PLACEMENT-ID", AdSize.BANNER_HEIGHT_50);
// Find the Ad Container
LinearLayout adContainer = (LinearLayout) findViewById(R.id.banner_container);
// Add the ad view to your activity layout
adContainer.addView(adView);
AdSettings.addTestDevice("DEVICE-ID");
// Request an ad
adView.loadAd();
}
#Override
protected void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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="liveradio.radioz.com.facebookads.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" />
<LinearLayout
android:id="#+id/banner_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
/>
</android.support.constraint.ConstraintLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="liveradio.radioz.com.facebookads">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<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>
</application>
</manifest>
Log :
01/12 12:13:01: Launching app
$ adb shell am start -n "liveradio.radioz.com.facebookads/liveradio.radioz.com.facebookads.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: liveradio.radioz.com.facebookads.test | liveradio.radioz.com.facebookads
Waiting for application to come online: liveradio.radioz.com.facebookads.test | liveradio.radioz.com.facebookads
Waiting for application to come online: liveradio.radioz.com.facebookads.test | liveradio.radioz.com.facebookads
Connecting to liveradio.radioz.com.facebookads
Waiting for application to start debug server
Waiting for application to come online: liveradio.radioz.com.facebookads.test | liveradio.radioz.com.facebookads
Connecting to liveradio.radioz.com.facebookads
Connected to the target VM, address: 'localhost:8645', transport: 'socket'
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/zygote: Not late-enabling -Xcheck:jni (already on)
W/zygote: Suspending all threads took: 83.944ms
W/zygote: Unexpected CPU variant for X86 using defaults: x86
I/zygote: Background concurrent copying GC freed 9752(4MB) AllocSpace objects, 0(0B) LOS objects, 61% free, 973KB/2MB, paused 48.188ms total 236.235ms
W/ActivityThread: Application liveradio.radioz.com.facebookads is waiting for the debugger on port 8100...
I/System.out: Sending WAIT chunk
I/zygote: Debugger is active
I/System.out: Debugger has connected
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: waiting for debugger to settle...
I/System.out: debugger has settled (1486)
I/InstantRun: starting instant run server: is main process
I/WebViewFactory: Loading com.android.chrome version 61.0.3163.98 (code 316409812)
I/zygote: The ClassLoaderContext is a special shared library.
I/cr_LibraryLoader: Time to load native libraries: 3 ms (timestamps 6510-6513)
I/chromium: [INFO:library_loader_hooks.cc(136)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_LibraryLoader: Expected native library version number "61.0.3163.98", actual native library version number "61.0.3163.98"
E/FBAudienceNetwork: You don't call AudienceNetworkAds.initialize(). Some functionality may not work properly.
D/IS_UNITY: false
D/AdInternalSettings: Test mode device hash: 877dd37b-fff7-4fa1-b83d-776592220359
D/AdInternalSettings: When testing your app with Facebook's ad units you must specify the device hashed ID to ensure the delivery of test ads, add the following code before loading an ad: AdSettings.addTestDevice("877dd37b-fff7-4fa1-b83d-776592220359");
D/IS_UNITY: false
E/ActivityThread: Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider
D/OpenGLRenderer: HWUI GL Pipeline
V/StudioProfiler: StudioProfilers agent attached.
V/StudioProfiler: Acquiring Application for Events
V/StudioProfiler: Transformed class: java/net/URL
W/zygote: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!
V/StudioProfiler: Memory control stream started.
[ 01-12 12:13:06.606 20774:20877 D/ ]
HostConnection::get() New Host Connection established 0xd1835a80, tid 20877
I/zygote: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
D/OpenGLRenderer: Swap behavior 0
D/EGL_emulation: eglCreateContext: 0xe4b85540: maj 3 min 0 rcv 3
D/EGL_emulation: eglMakeCurrent: 0xe4b85540: ver 3 0 (tinfo 0xe4b83360)
D/EGL_emulation: eglMakeCurrent: 0xe4b85540: ver 3 0 (tinfo 0xe4b83360)
W/cr_ChildProcLH: Create a new ChildConnectionAllocator with package name = com.android.chrome, sandboxed = true
I/cr_BrowserStartup: Initializing chromium process, singleProcess=false
[ 01-12 12:13:07.026 20774:20774 D/ ]
HostConnection::get() New Host Connection established 0xd1583c00, tid 20774
D/EGL_emulation: eglCreateContext: 0xcecec360: maj 3 min 0 rcv 3
D/EGL_emulation: eglMakeCurrent: 0xcecec360: ver 3 0 (tinfo 0xe21fff60)
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
W/cr_CrashFileManager: /data/user/0/liveradio.radioz.com.facebookads/cache/WebView/Crash Reports does not exist or is not a directory
W/com.facebookads: type=1400 audit(0.0:22): avc: denied { read } for name="vmstat" dev="proc" ino=4026532039 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0
D/IS_UNITY: false
I/zygote: Background concurrent copying GC freed 7886(1025KB) AllocSpace objects, 5(100KB) LOS objects, 50% free, 1746KB/3MB, paused 680us total 122.639ms
I/zygote: Do partial code cache collection, code=30KB, data=25KB
I/zygote: After code cache collection, code=30KB, data=25KB
I/zygote: Increasing code cache capacity to 128KB
V/StudioProfiler: Live memory tracking disabled.
V/StudioProfiler: Live memory tracking enabled.
V/StudioProfiler: JNIEnv not attached
V/StudioProfiler: Loaded classes: 6311
V/StudioProfiler: Tracking initialization took: 648527000ns
I/zygote: Do partial code cache collection, code=60KB, data=44KB
I/zygote: After code cache collection, code=56KB, data=43KB
I/zygote: Increasing code cache capacity to 256KB
Disconnected from the target VM, address: 'localhost:8645', transport: 'socket'
I'm getting the build successful and installed in my device. When I open the app I can't see any ads or test ads at bottom of my main activity.
If you've added Audience network libraries, you can add the code below to show test ads without worrying about adding a test device.
if (BuildConfig.DEBUG) {
AdSettings.setTestMode(true);
}
Add this code, preferably in your Application class.
First Implement this library:
implementation 'com.facebook.android:audience-network-sdk:4.99.1'
than use below code:
com.facebook.ads.AdView adView;
adView = new com.facebook.ads.AdView(this, "PLACEMENT-ID",
com.facebook.ads.AdSize.BANNER_HEIGHT_50);
((LinearLayout) adContainer).addView(adView);
adView.loadAd();
first, add this library to your grade file
implementation 'com.facebook.android:audience-network-sdk:6.12.0'
then paste this code in your xml file
<LinearLayout
android:id="#+id/banner_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
/>
In your Java code paste this code and also replace IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID with your banner ad ID
adView = new AdView(this, "IMG_16_9_APP_INSTALL#YOUR_PLACEMENT_ID", AdSize.BANNER_HEIGHT_50);
LinearLayout adContainer = (LinearLayout) findViewById(R.id.banner_container);
adContainer.addView(adView);
adView.loadAd();
for more information you can follow official link of meta
https://developers.facebook.com/docs/audience-network/setting-up/ad-setup/android/banner

How to properly change UI theme?

I want a dark colored theme.
I changed the following in styles.xml:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
to
<style name="AppTheme" parent="android:Theme.Black">
and I also tried many other strings which either don't compile or cause the same crash.
Android monitor shows:
08-11 20:07:00.938 29773-29773/? I/zygote: Not late-enabling -Xcheck:jni (already on)
08-11 20:07:00.956 29773-29773/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
08-11 20:07:01.122 29773-29773/com.example.timothyswan.myapplication I/InstantRun: starting instant run server: is main process
08-11 20:07:01.283 29773-29805/com.example.timothyswan.myapplication D/OpenGLRenderer: HWUI GL Pipeline
08-11 20:07:01.457 29773-29805/com.example.timothyswan.myapplication I/OpenGLRenderer: Initialized EGL, version 1.4
08-11 20:07:01.457 29773-29805/com.example.timothyswan.myapplication D/OpenGLRenderer: Swap behavior 1
08-11 20:07:01.457 29773-29805/com.example.timothyswan.myapplication W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
08-11 20:07:01.457 29773-29805/com.example.timothyswan.myapplication D/OpenGLRenderer: Swap behavior 0
08-11 20:07:01.459 29773-29805/com.example.timothyswan.myapplication D/EGL_emulation: eglCreateContext: 0xaa4b1920: maj 2 min 0 rcv 2
08-11 20:07:01.461 29773-29805/com.example.timothyswan.myapplication D/EGL_emulation: eglMakeCurrent: 0xaa4b1920: ver 2 0 (tinfo 0x9e4aa9f0)
[ 08-11 20:07:01.479 29773:29805 D/ ]
SurfaceInterface::setAsyncMode: set async mode 1
08-11 20:07:01.493 29773-29805/com.example.timothyswan.myapplication D/EGL_emulation: eglMakeCurrent: 0xaa4b1920: ver 2 0 (tinfo 0x9e4aa9f0)
And the 'run' console shows:
08/11 22:01:07: Launching app
$ adb shell am start -n "com.example.timothyswan.myapplication/com.example.timothyswan.myapplication.InspirationBasic" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Client not ready yet..Waiting for process to come online
Connected to process 6973 on device emulator-5554
Application terminated.
The theme of an AppCompatActivity (not Activity) must be an descendant of an Theme.AppCompat.
So check if your activity extends AppCompatActivity or not.
If so, change it extends Activity, or make your own theme which inherits from Theme.AppCompat and apply to your activity

How to make a post request to a rails app using android and retrofit

I have setup rails api using the scaffold generator. so my controller looks like this
Rails PostsController
class PostsController < ApplicationController
before_action :set_post, only: [:show, :update, :destroy]
def index
#posts = Post.all
render json: #posts
end
def show
render json: #post
end
def create
#post = Post.new(post_params)
if #post.save
render json: #post, status: :created, location: #post
else
render json: #post.errors, status: :unprocessable_entity
end
end
def update
if #post.update(post_params)
render json: #post
else
render json: #post.errors, status: :unprocessable_entity
end
end
def destroy
#post.destroy
end
private
def set_post
#post = Post.find(params[:id])
end
def post_params
params.require(:post).permit(:title, :body, :userId)
end
end
running this curl command
curl -i -X POST -H "Content-Type:application/json" www.example.com/posts/ -d '{"title":"foo", "body":"bar"}'
{"id":4,"title":"foo","body":"bar","created_at":"2017-06-12T19:11:26.752Z","updated_at":"2017-06-12T19:11:26.752Z"}
I then setup the android app following this tutorial Sending Data With Retrofit 2 HTTP Client for Android
running the app using the link on the tutorial works.when I replace it with my rails app url I get the following
06-12 21:44:01.352 31991-31991/? I/zygote: Not late-enabling -Xcheck:jni (already on)
06-12 21:44:01.365 31991-31991/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
06-12 21:44:01.403 31991-31999/? E/zygote: Failed writing handshake bytes (-1 of 14): Broken pipe
06-12 21:44:01.403 31991-31999/? I/zygote: Debugger is no longer active
06-12 21:44:01.494 31991-31991/? I/InstantRun: starting instant run server: is main process
06-12 21:44:01.600 31991-31991/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default
06-12 21:44:01.614 31991-32018/? D/OpenGLRenderer: HWUI GL Pipeline
[ 06-12 21:44:01.635 31991:32018 D/ ]
HostConnection::get() New Host Connection established 0xa95e4f00, tid 32018
06-12 21:44:01.637 31991-32018/? I/OpenGLRenderer: Initialized EGL, version 1.4
06-12 21:44:01.637 31991-32018/? D/OpenGLRenderer: Swap behavior 1
06-12 21:44:01.637 31991-32018/? W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
06-12 21:44:01.637 31991-32018/? D/OpenGLRenderer: Swap behavior 0
06-12 21:44:01.640 31991-32018/? D/EGL_emulation: eglCreateContext: 0xa718b220: maj 2 min 0 rcv 2
06-12 21:44:01.655 31991-32018/? D/EGL_emulation: eglMakeCurrent: 0xa718b220: ver 2 0 (tinfo 0xa95ccb10)
06-12 21:44:01.668 31991-32018/? W/android.hardware.graphics.mapper#2.0::Mapper: getService: found null hwbinder interface
06-12 21:44:01.672 31991-32018/? I/vndksupport: sphal namespace is not configured for this process. Loading /system/lib/hw/gralloc.ranchu.so from the current namespace instead.
06-12 21:44:01.707 31991-32018/? D/EGL_emulation: eglMakeCurrent: 0xa718b220: ver 2 0 (tinfo 0xa95ccb10)
and submitting the form give me
06-12 21:46:52.742 31991-31997/com.kainet.retropost I/zygote: Do partial code cache collection, code=122KB, data=90KB
06-12 21:46:52.743 31991-31997/com.kainet.retropost I/zygote: After code cache collection, code=122KB, data=90KB
06-12 21:46:52.743 31991-31997/com.kainet.retropost I/zygote: Increasing code cache capacity to 512KB
How can I fix this?
I replaced the base_url from
public static final String BASE_URL = "http://www.example.com/api/v1";
to
public static final String BASE_URL = "http://www.example.com/";
and the interface from
public interface APIService {
#POST("/posts")
#FormUrlEncoded
Call<Imei> sendPost(#Field("title") String title);
}
to
public interface APIService {
#POST("/api/v1/posts")
#FormUrlEncoded
Call<Imei> sendPost(#Field("title") String title);
}

'Unfortunately, app has stopped' is shown twice on the device and 'Application terminated' in android studio with no error being shown

I am developing an app using Android Studio.
The problem is that app gets crashed twice within few minutes of running it and besides Application terminated. and normal logs no error is shown in the logcat.
Here's complete logcat:
02/12 22:31:34: Launching app
Cold swapped changes.
$ adb shell am start -n "com.abc.xxx/com.abc.xxx.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 13399 on device micromax-micromax_aq4502-2864004C04884I2
I/art: Late-enabling -Xcheck:jni
W/System: ClassLoader referenced unknown path: /data/app/com.abc.xxx-2/lib/arm
I/InstantRun: Instant Run Runtime started. Android package is com.abc.xxx, real application class is null.
W/System: ClassLoader referenced unknown path: /data/app/com.abc.xxx-2/lib/arm
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
I/art: Background sticky concurrent mark sweep GC freed 11281(1218KB) AllocSpace objects, 22(696KB) LOS objects, 15% free, 5MB/6MB, paused 13.077ms total 70.659ms
I/DynamiteModule: Considering local module com.google.android.gms.flags:2 and remote module com.google.android.gms.flags:0
I/DynamiteModule: Selected local version of com.google.android.gms.flags
W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
I/DynamiteModule: Considering local module com.google.android.gms.crash:0 and remote module com.google.android.gms.crash:4
I/DynamiteModule: Selected remote version of com.google.android.gms.crash, version >= 4
W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000012/n/armeabi-v7a
W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000012/n/armeabi
I/FirebaseCrashApiImpl: FirebaseCrashApiImpl created by ClassLoader p[DexPathList[[zip file "/data/data/com.google.android.gms/app_chimera/m/00000012/DynamiteModulesC_GmsCore_prodmnc_hdpi_release.apk"],nativeLibraryDirectories=[/data/user/0/com.google.android.gms/app_chimera/m/00000012/n/armeabi-v7a, /data/user/0/com.google.android.gms/app_chimera/m/00000012/n/armeabi, /vendor/lib, /system/lib]]]
I/DynamiteModule: Considering local module com.google.android.gms.flags:2 and remote module com.google.android.gms.flags:0
I/DynamiteModule: Selected local version of com.google.android.gms.flags
W/DynamiteModule: Local module descriptor class for com.google.android.gms.crash not found.
I/FA: App measurement is starting up, version: 10084
I/FA: To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
D/FA: Debug-level message logging enabled
D/FA: AppMeasurement singleton hash: 198168520
V/FA: Collection enabled
V/FA: App package, google app id: com.abc.xxx, 1:987905869088:android:e7f50263e7b8aa58
I/FA: To enable faster debug mode event logging run:
adb shell setprop debug.firebase.analytics.app com.getsportalapp.sportal
V/FA: Registered activity lifecycle callback
I/FirebaseCrash: FirebaseCrash reporting initialized com.google.android.gms.internal.zzbks#e551d72
I/FirebaseInitProvider: FirebaseApp initialization successful
V/FA: Using measurement service
V/FA: Connecting to remote service
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
W/com.facebook.appevents.AppEventsLogger: activateApp events are being logged automatically. There's no need to call activateApp explicitly, this is safe to remove.
I/GAC: Building GoogleApiClient
I/CrashlyticsCore: Initializing Crashlytics 2.3.15.167
V/FA: Connection attempt already in progress
V/FA: Activity resumed, time: 824779068
D/OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: false
D/signedIn: onAuthStateChanged:signed_in:ShXMXdc5kHUQZWG3lGudJtt2
I/DynamiteModule: Considering local module com.google.android.gms.firebase_database:4 and remote module com.google.android.gms.firebase_database:5
I/DynamiteModule: Selected remote version of com.google.android.gms.firebase_database, version >= 5
I/OpenGLRenderer: Initialized EGL, version 1.4
I/MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0
I/MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1
I/MaliEGL: [Mali]max_allowed_dequeued_buffers=3
E/RecyclerView: No adapter attached; skipping layout
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 2
E/RecyclerView: No adapter attached; skipping layout
D/getInvitation: getInvitation: no deep link found.
D/called: again
D/cLat: 2.8418744
D/cLng: 8.7791019
I/MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0
I/MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1
I/MaliEGL: [Mali]max_allowed_dequeued_buffers=3
W/PersistentConnection: pc_0 - Using an unspecified index. Consider adding '".indexOn": "g"' at geofire to your security and Firebase Database rules for better performance
W/PersistentConnection: pc_0 - Using an unspecified index. Consider adding '".indexOn": "g"' at geofire to your security and Firebase Database rules for better performance
W/PersistentConnection: pc_0 - Using an unspecified index. Consider adding '".indexOn": "g"' at geofire to your security and Firebase Database rules for better performance
W/PersistentConnection: pc_0 - Using an unspecified index. Consider adding '".indexOn": "g"' at geofire to your security and Firebase Database rules for better performance
W/Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000010/n/armeabi
D/DynamitePackage: Instantiated singleton DynamitePackage.
D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
I/DynamiteModule: Considering local module com.google.android.gms.piccard.dynamite:0 and remote module com.google.android.gms.piccard.dynamite:12
I/DynamiteModule: Selected remote version of com.google.android.gms.piccard.dynamite, version >= 12
W/System: ClassLoader referenced unknown path: /data/user/0/com.google.android.gms/app_chimera/m/00000010/n/armeabi
W/VideoCapabilities: Unrecognized profile/level 32768/2 for video/mp4v-es
I/VideoCapabilities: Unsupported profile 8 for video/mp4v-es
I/VideoCapabilities: Unsupported profile 8 for video/mp4v-es
I/VideoCapabilities: Unsupported profile 8 for video/mp4v-es
I/VideoCapabilities: Unsupported profile 8 for video/mp4v-es
I/VideoCapabilities: Unsupported profile 8 for video/mp4v-es
I/VideoCapabilities: Unsupported profile 8 for video/mp4v-es
I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
I/Ads: Starting ad request.
I/WebViewFactory: Loading com.google.android.webview version 53.0.2785.124 (code 278512400)
D/diffAnother: -6283000
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
I/art: Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
I/cr_LibraryLoader: Time to load native libraries: 6 ms (timestamps 5738-5744)
I/cr_LibraryLoader: Expected native library version number "53.0.2785.124", actual native library version number "53.0.2785.124"
V/WebViewChromiumFactoryProvider: Binding Chromium to main looper Looper (main, tid 1) {611ead6}
I/cr_LibraryLoader: Expected native library version number "53.0.2785.124", actual native library version number "53.0.2785.124"
I/chromium: [INFO:library_loader_hooks.cc(151)] Chromium logging enabled: level = 0, default verbosity = 0
I/cr_BrowserStartup: Initializing chromium process, singleProcess=true
W/cr_media: Requires BLUETOOTH permission
W/cr_AwContents: onDetachedFromWindow called when already detached. Ignoring
I/cr_Ime: ImeThread is not enabled.
E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 13399
I/DynamiteModule: Considering local module com.google.android.gms.tagmanager:8 and remote module com.google.android.gms.tagmanager:9
I/DynamiteModule: Selected remote version of com.google.android.gms.tagmanager, version >= 9
W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.
W/GoogleTagManager: No container asset found in /assets/containers. Checking top level /assets directory for container assets.
W/GoogleTagManager: Tag Manager's event handler WILL NOT be installed (no container loaded)
I/GoogleTagManager: Tag Manager initilization took 213ms
V/FA: Using measurement service
V/FA: Connecting to remote service
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 1
I/Ads: Scheduling ad refresh 45000 milliseconds from now.
W/cr_AwContents: onDetachedFromWindow called when already detached. Ignoring
I/cr_Ime: ImeThread is not enabled.
I/Ads: Ad finished loading.
W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 13399
I/chromium: [INFO:CONSOLE(0)] "Document was loaded from Application Cache with manifest https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.appcache", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
I/chromium: [INFO:CONSOLE(0)] "Application Cache Checking event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
I/chromium: [INFO:CONSOLE(0)] "Application Cache NoUpdate event", source: https://googleads.g.doubleclick.net/mads/static/mad/sdk/native/sdk-core-v40-loader.html (0)
D/diffAnother: 1129000
D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
I/Ads: Starting ad request.
D/diffAnother: -6300000
W/cr_AwContents: onDetachedFromWindow called when already detached. Ignoring
I/cr_Ime: ImeThread is not enabled.
W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 13399
I/Ads: Scheduling ad refresh 45000 milliseconds from now.
I/Ads: Ad finished loading.
V/FA: Using measurement service
V/FA: Connecting to remote service
D/FA: Logging event (FE): _e, Bundle[{_o=auto, _et=29568, _sc=MainActivity, _si=-6311178554893906199}]
V/FA: Using measurement service
V/FA: Connection attempt already in progress
V/FA: Activity paused, time: 824808635
D/FA: Connected to remote service
V/FA: Processing queued up service tasks: 2
W/com.facebook.appevents.AppEventsLogger: activateApp events are being logged automatically. There's no need to call activateApp explicitly, this is safe to remove.
I/MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0
I/MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1
I/MaliEGL: [Mali]max_allowed_dequeued_buffers=3
D/call1: called
D/call2: called
D/call1: called
D/call2: called
D/error1: ERROR1
D/error1: ERROR1
I/MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0
I/MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1
I/MaliEGL: [Mali]max_allowed_dequeued_buffers=3
V/RenderScript: 0xb8457a88 Launching thread(s), CPUs 4
I/MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0
I/MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1
I/MaliEGL: [Mali]max_allowed_dequeued_buffers=3
V/FA: Inactivity, disconnecting from the service
I/MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0
I/MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1
I/MaliEGL: [Mali]max_allowed_dequeued_buffers=3
I/MaliEGL: [Mali]window_type=1, is_framebuffer=0, errnum = 0
I/MaliEGL: [Mali]surface->num_buffers=4, surface->num_frames=3, win_min_undequeued=1
I/MaliEGL: [Mali]max_allowed_dequeued_buffers=3
I/Ads: Ad is not visible. Not refreshing ad.
I/Ads: Scheduling ad refresh 60000 milliseconds from now.
I/Ads: Ad is not visible. Not refreshing ad.
I/Ads: Scheduling ad refresh 60000 milliseconds from now.
Application terminated.
I tried integrating crashlytics but even it doesn't show any error when the app crashes in this manner.
The question is how will I be able to fix the error if I don't even know what the error is?
Please help me with this.
I think the issue is related to your ad view.
In last line it is showing that ad is not visible.

Categories

Resources