React-Native App Crashes in Physical Android Device (When Dev Settings Pressed) - android

So I have a react-native app and it works fine in my simulat in computer, but when I want to check it in real device I get errors..
1.I run react-native run-android (app installs to real device, with just giving warning about adb reverse, cuz device's android version is
4.4.2)
2.When app opens in real device, says "Unable to load script from assets etc."
3.Then I try to open Dev Settings to connect to bundle via wifi as suggested and My app crashes!.. I tried in 2 different devices it
crashed in both.
I tracked it with android device monitor and I get some errors starting with :
07-18 17:03:24.596: E/AndroidRuntime(1160):
android.view.InflateException: Binary XML file line #19: Error
inflating class android.widget.CheckBox 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.view.LayoutInflater.createView(LayoutInflater.java:626) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.view.LayoutInflater.onCreateView(LayoutInflater.java:675)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:700)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.view.LayoutInflater.inflate(LayoutInflater.java:470) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.LayoutInflater.inflate(LayoutInflater.java:398) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.LayoutInflater.inflate(LayoutInflater.java:354) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.preference.Preference.onCreateView(Preference.java:531) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.preference.Preference.getView(Preference.java:494) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.preference.PreferenceGroupAdapter.getView(PreferenceGroupAdapter.java:222)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.widget.AbsListView.obtainView(AbsListView.java:2742) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.widget.ListView.makeAndAddView(ListView.java:1811) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.widget.ListView.fillDown(ListView.java:697) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.widget.ListView.fillFromTop(ListView.java:763) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.widget.ListView.layoutChildren(ListView.java:1641) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.widget.AbsListView.onLayout(AbsListView.java:2567) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.View.layout(View.java:15819) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.view.ViewGroup.layout(ViewGroup.java:4884) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.widget.LinearLayout.onLayout(LinearLayout.java:1440) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.View.layout(View.java:15819) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.view.ViewGroup.layout(ViewGroup.java:4884) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1666)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.widget.LinearLayout.onLayout(LinearLayout.java:1442) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.View.layout(View.java:15819) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.view.ViewGroup.layout(ViewGroup.java:4884) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.widget.LinearLayout.onLayout(LinearLayout.java:1440) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.View.layout(View.java:15819) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.view.ViewGroup.layout(ViewGroup.java:4884) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.widget.FrameLayout.onLayout(FrameLayout.java:388) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.View.layout(View.java:15819) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.view.ViewGroup.layout(ViewGroup.java:4884) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.widget.LinearLayout.setChildFrame(LinearLayout.java:1677)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.widget.LinearLayout.layoutVertical(LinearLayout.java:1531)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.widget.LinearLayout.onLayout(LinearLayout.java:1440) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.View.layout(View.java:15819) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.view.ViewGroup.layout(ViewGroup.java:4884) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.widget.FrameLayout.layoutChildren(FrameLayout.java:453) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.widget.FrameLayout.onLayout(FrameLayout.java:388) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.View.layout(View.java:15819) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.view.ViewGroup.layout(ViewGroup.java:4884) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2391) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2099)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1270) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6721)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.view.Choreographer$CallbackRecord.run(Choreographer.java:812)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.view.Choreographer.doCallbacks(Choreographer.java:612) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.Choreographer.doFrame(Choreographer.java:582) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:798)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
android.os.Handler.handleCallback(Handler.java:733) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.os.Handler.dispatchMessage(Handler.java:95) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
android.os.Looper.loop(Looper.java:146) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
android.app.ActivityThread.main(ActivityThread.java:5641) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
java.lang.reflect.Method.invokeNative(Native Method) 07-18
17:03:24.596: E/AndroidRuntime(1160): at
java.lang.reflect.Method.invoke(Method.java:515) 07-18 17:03:24.596:
E/AndroidRuntime(1160): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1288)
07-18 17:03:24.596: E/AndroidRuntime(1160): at
com.android.internal.os.Zygote 07-18 17:03:24.656: A/libc(1215): Fatal
signal 13 (SIGPIPE) at 0x000004bf (code=0), thread 1215 (uptime)
Any ideas how I can solve this..?
app/android/app/build.gradle :
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.gotl"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile project(':react-native-track-player')
compile project(':react-native-sound-player')
compile project(':react-native-sound')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.facebook.fresco:animated-gif:1.3.0'
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}

I want to share that I noticed it crashes in android 4.4.4 version, but its not crashing in 5.0 version.. So anyone have some idea about it?..

Related

Android Eclipse App Crashes on Launch

I'm new to developing for Android and I'm having trouble launching my project. Whenever I launch it, it crashes and I get an error. I've put breakpoints throughout my code but it crashes before it reaches them. Here is the output from LogCat:
07-18 18:22:17.695: I/System.out(32229): Sending WAIT chunk
07-18 18:22:17.695: W/ActivityThread(32229): Application com.amvara.skatometer is waiting for the debugger on port 8100...
07-18 18:22:17.945: I/dalvikvm(32229): Debugger is active
07-18 18:22:18.095: I/System.out(32229): Debugger has connected
07-18 18:22:18.095: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.295: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.500: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.700: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:18.900: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.100: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.300: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.500: I/System.out(32229): waiting for debugger to settle...
07-18 18:22:19.705: I/System.out(32229): debugger has settled (1434)
07-18 18:22:19.735: W/dalvikvm(32229): Unable to resolve superclass of Lcom/amvara/skatometer/ItemListActivity; (29)
07-18 18:22:19.735: W/dalvikvm(32229): Link of class 'Lcom/amvara/skatometer/ItemListActivity;' failed
07-18 18:22:19.745: D/AndroidRuntime(32229): Shutting down VM
07-18 18:22:19.745: W/dalvikvm(32229): threadid=1: thread exiting with uncaught exception (group=0x410d62a0)
07-18 18:22:19.780: E/AndroidRuntime(32229): FATAL EXCEPTION: main
07-18 18:22:19.780: E/AndroidRuntime(32229): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.amvara.skatometer/com.amvara.skatometer.ItemListActivity}: java.lang.ClassNotFoundException: com.amvara.skatometer.ItemListActivity
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2024)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.access$600(ActivityThread.java:140)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1227)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.os.Looper.loop(Looper.java:137)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.main(ActivityThread.java:4898)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.reflect.Method.invokeNative(Native Method)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.reflect.Method.invoke(Method.java:511)
07-18 18:22:19.780: E/AndroidRuntime(32229): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
07-18 18:22:19.780: E/AndroidRuntime(32229): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
07-18 18:22:19.780: E/AndroidRuntime(32229): at dalvik.system.NativeStart.main(Native Method)
07-18 18:22:19.780: E/AndroidRuntime(32229): Caused by: java.lang.ClassNotFoundException: com.amvara.skatometer.ItemListActivity
07-18 18:22:19.780: E/AndroidRuntime(32229): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-18 18:22:19.780: E/AndroidRuntime(32229): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.Instrumentation.newActivity(Instrumentation.java:1057)
07-18 18:22:19.780: E/AndroidRuntime(32229): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2015)
07-18 18:22:19.780: E/AndroidRuntime(32229): ... 11 more
I can't figure out why this would happen because it isn't even hitting a breakpoint in my code. It must be a problem in the auto-generated Android code. Here's my AndroidManifest.xml, if you need it:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.amvara.skatometer"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.amvara.skatometer.ItemListActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.amvara.skatometer.ItemDetailActivity"
android:label="#string/title_item_detail"
android:parentActivityName=".ItemListActivity" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ItemListActivity" />
</activity>
<activity
android:name="com.amvara.skatometer.Bottom_panel"
android:label="#string/title_activity_bottom_panel" >
</activity>
<activity
android:name="com.amvara.skatometer.General"
android:label="#string/title_activity_general" >
</activity>
<activity
android:name="com.amvara.skatometer.SettingsActivity"
android:label="#string/title_activity_settings" >
</activity>
</application>
</manifest>
Thanks.
Try to clean your project, then you can also change :
<activity
android:name="com.amvara.skatometer.ItemListActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" >
[...]
</activity>
By
<activity
android:name=".ItemListActivity"
android:label="#string/app_name"
android:screenOrientation="sensorLandscape" >
[...]
</activity>
It append to me one time but after all modification, doesn't work so I recreate the project from scratch and imported all my class, layout, etc. At the end, works as well.

SplashScreen using PNG image leads to Android.Views.InflateException followed by OutOfMemory

I watched Google IO 2011 conference, read almost every post about OutOfMemory Exception and InflateException, no luck, I cannot find any answer that solve my problem.
How can I properly clear memory from a layout containing a background image? I feel like if the InflateException followed by OutOfMemory are related because that background image is not cleared properly.
So I'm getting :
Android.Views.InflateException: Binary XML file line #24: Error
inflating class
followed by :
Java.Lang.OutOfMemoryError:
Which I'm pretty sure is caused by my background image.
I simplified my code to narrow the problem as much as possible.
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="12" android:targetSdkVersion="12" />
<activity />
<application android:theme="#android:style/Theme.NoTitleBar" parent="android:Theme"/>
</manifest>
I added parent="android:Theme" which was suppose to fix the issue, no success.
SplashScreen.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/SplashScreenView"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/splash" />
splash is a .png image located in my drawable folder.
SplashScreenActivity.cs
[Activity(Label = "My splash screen", MainLauncher = true)]
public class SplashScreenActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.SplashScreen);
StartNextActivity();
}
private void StartNextActivity()
{
var intent = new Intent(this, typeof(SplashScreenActivity));
intent.SetFlags(ActivityFlags.ClearWhenTaskReset | ActivityFlags.NewTask);
StartActivity(intent);
Finish();
}
public override void Finish()
{
base.Finish();
var view = FindViewById<LinearLayout>(Resource.Id.SplashScreenView);
view.Background.SetCallback(null);
view.Background.Dispose();
view.DestroyDrawingCache();
Resources.FlushLayoutCache();
}
}
First I do load the SplashScreenActivity continuously, this is intentional to make the errors happen sooner.
As you can see, I tried several things to clear the Background image, setting flags or explicitly trying to dispose it.
On the first load I get those messages, which seems to be ok since it is loading the image :
07-18 12:14:22.472 I/dalvikvm-heap(30085): Grow heap (frag case) to 10.600MB for 2949136-byte allocation
07-18 12:14:22.522 D/dalvikvm(30085): GC_CONCURRENT freed 76K, 7% free 9432K/10119K, paused 2ms+1ms
However, it keep growing up until I consume all the device available memory :
07-18 12:12:17.852 I/dalvikvm-heap(18665): Clamp target GC heap from 68.605MB to 64.000MB
07-18 12:12:17.852 D/dalvikvm(18665): GC_FOR_ALLOC freed 73K, 1% free 65064K/65543K, paused 338ms
07-18 12:12:17.852 I/dalvikvm-heap(18665): Forcing collection of SoftReferences for 1576-byte allocation
07-18 12:12:18.212 I/dalvikvm-heap(18665): Clamp target GC heap from 68.604MB to 64.000MB
07-18 12:12:18.212 D/dalvikvm(18665): GC_BEFORE_OOM freed <1K, 1% free 65064K/65543K, paused 362ms
07-18 12:12:18.212 E/dalvikvm-heap(18665): Out of memory on a 1576-byte allocation.
07-18 12:12:18.212 I/dalvikvm(18665): "main" prio=5 tid=1 RUNNABLE
07-18 12:12:18.212 I/dalvikvm(18665): | group="main" sCount=0 dsCount=0 obj=0x40a45460 self=0xb068a0
07-18 12:12:18.212 I/dalvikvm(18665): | sysTid=18665 nice=0 sched=0/0 cgrp=default handle=1074517128
07-18 12:12:18.212 I/dalvikvm(18665): | schedstat=( 71462466000 19081532000 88403 ) utm=6360 stm=786 core=0
07-18 12:12:18.212 I/dalvikvm(18665): at android.content.res.Resources.getCachedStyledAttributes(Resources.java:~2193)
07-18 12:12:18.212 I/dalvikvm(18665): at android.content.res.Resources.access$000(Resources.java:71)
07-18 12:12:18.212 I/dalvikvm(18665): at android.content.res.Resources$Theme.obtainStyledAttributes(Resources.java:1260)
07-18 12:12:18.212 I/dalvikvm(18665): at android.content.Context.obtainStyledAttributes(Context.java:364)
07-18 12:12:18.212 I/dalvikvm(18665): at android.view.View.<init>(View.java:2746)
07-18 12:12:18.222 I/dalvikvm(18665): at android.view.ViewGroup.<init>(ViewGroup.java:385)
07-18 12:12:18.222 I/dalvikvm(18665): at android.widget.LinearLayout.<init>(LinearLayout.java:174)
07-18 12:12:18.222 I/dalvikvm(18665): at android.widget.LinearLayout.<init>(LinearLayout.java:170)
07-18 12:12:18.222 I/dalvikvm(18665): at java.lang.reflect.Constructor.constructNative(Native Method)
07-18 12:12:18.222 I/dalvikvm(18665): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
07-18 12:12:18.222 I/dalvikvm(18665): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
07-18 12:12:18.222 I/dalvikvm(18665): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-18 12:12:18.222 I/dalvikvm(18665): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
07-18 12:12:18.222 I/dalvikvm(18665): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
07-18 12:12:18.222 I/dalvikvm(18665): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
07-18 12:12:18.222 I/dalvikvm(18665): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-18 12:12:18.222 I/dalvikvm(18665): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-18 12:12:18.222 I/dalvikvm(18665): at com.android.internal.policy.impl.PhoneWindow.generateLayout(PhoneWindow.java:2707)
07-18 12:12:18.222 I/dalvikvm(18665): at com.android.internal.policy.impl.PhoneWindow.installDecor(PhoneWindow.java:2767)
07-18 12:12:18.222 I/dalvikvm(18665): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:247)
07-18 12:12:18.222 I/dalvikvm(18665): at android.app.Activity.setContentView(Activity.java:1835)
07-18 12:12:18.222 I/dalvikvm(18665): at myFirstApp.android.activities.SplashScreenActivity.n_onCreate(Native Method)
07-18 12:12:18.222 I/dalvikvm(18665): at myFirstApp.android.activities.SplashScreenActivity.onCreate(SplashScreenActivity.java:30)
07-18 12:12:18.222 I/dalvikvm(18665): at android.app.Activity.performCreate(Activity.java:4465)
07-18 12:12:18.222 I/dalvikvm(18665): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-18 12:12:18.222 I/dalvikvm(18665): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
07-18 12:12:18.222 I/dalvikvm(18665): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-18 12:12:18.222 I/dalvikvm(18665): at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-18 12:12:18.222 I/dalvikvm(18665): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-18 12:12:18.222 I/dalvikvm(18665): at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 12:12:18.222 I/dalvikvm(18665): at android.os.Looper.loop(Looper.java:137)
07-18 12:12:18.222 I/dalvikvm(18665): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-18 12:12:18.222 I/dalvikvm(18665): at java.lang.reflect.Method.invokeNative(Native Method)
07-18 12:12:18.222 I/dalvikvm(18665): at java.lang.reflect.Method.invoke(Method.java:511)
07-18 12:12:18.222 I/dalvikvm(18665): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-18 12:12:18.222 I/dalvikvm(18665): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-18 12:12:18.222 I/dalvikvm(18665): at dalvik.system.NativeStart.main(Native Method)
07-18 12:12:18.222 I/dalvikvm(18665):
07-18 12:12:18.972 I/dalvikvm-heap(18665): Clamp target GC heap from 68.623MB to 64.000MB
07-18 12:12:18.972 D/dalvikvm(18665): GC_FOR_ALLOC freed 6K, 1% free 65082K/65543K, paused 341ms
07-18 12:12:18.982 I/dalvikvm-heap(18665): Forcing collection of SoftReferences for 1402-byte allocation
07-18 12:12:19.332 I/dalvikvm-heap(18665): Clamp target GC heap from 68.623MB to 64.000MB
07-18 12:12:19.332 D/dalvikvm(18665): GC_BEFORE_OOM freed <1K, 1% free 65082K/65543K, paused 358ms
07-18 12:12:19.332 E/dalvikvm-heap(18665): Out of memory on a 1402-byte allocation.
07-18 12:12:19.332 I/dalvikvm(18665): "main" prio=5 tid=1 RUNNABLE
07-18 12:12:19.332 I/dalvikvm(18665): | group="main" sCount=0 dsCount=0 obj=0x40a45460 self=0xb068a0
07-18 12:12:19.332 I/dalvikvm(18665): | sysTid=18665 nice=0 sched=0/0 cgrp=default handle=1074517128
07-18 12:12:19.342 I/dalvikvm(18665): | schedstat=( 72173821000 19107690000 88644 ) utm=6429 stm=788 core=0
07-18 12:12:19.342 I/dalvikvm(18665): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:~94)
07-18 12:12:19.342 I/dalvikvm(18665): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:124)
07-18 12:12:19.342 I/dalvikvm(18665): at java.lang.StringBuffer.append(StringBuffer.java:278)
07-18 12:12:19.342 I/dalvikvm(18665): at java.io.StringWriter.write(StringWriter.java:123)
07-18 12:12:19.342 I/dalvikvm(18665): at java.io.PrintWriter.doWrite(PrintWriter.java:623)
07-18 12:12:19.342 I/dalvikvm(18665): at java.io.PrintWriter.write(PrintWriter.java:601)
07-18 12:12:19.342 I/dalvikvm(18665): at java.io.PrintWriter.write(PrintWriter.java:579)
07-18 12:12:19.342 I/dalvikvm(18665): at java.io.PrintWriter.write(PrintWriter.java:660)
07-18 12:12:19.342 I/dalvikvm(18665): at java.io.PrintWriter.append(PrintWriter.java:722)
07-18 12:12:19.342 I/dalvikvm(18665): at java.io.PrintWriter.append(PrintWriter.java:691)
07-18 12:12:19.342 I/dalvikvm(18665): at java.io.PrintWriter.append(PrintWriter.java:31)
07-18 12:12:19.342 I/dalvikvm(18665): at java.lang.Throwable.printStackTrace(Throwable.java:329)
07-18 12:12:19.342 I/dalvikvm(18665): at java.lang.Throwable.printStackTrace(Throwable.java:305)
07-18 12:12:19.342 I/dalvikvm(18665): at myFirstApp.android.activities.SplashScreenActivity.n_onCreate(Native Method)
07-18 12:12:19.342 I/dalvikvm(18665): at myFirstApp.android.activities.SplashScreenActivity.onCreate(SplashScreenActivity.java:30)
07-18 12:12:19.342 I/dalvikvm(18665): at android.app.Activity.performCreate(Activity.java:4465)
07-18 12:12:19.342 I/dalvikvm(18665): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-18 12:12:19.342 I/dalvikvm(18665): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
07-18 12:12:19.342 I/dalvikvm(18665): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-18 12:12:19.342 I/dalvikvm(18665): at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-18 12:12:19.342 I/dalvikvm(18665): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-18 12:12:19.342 I/dalvikvm(18665): at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 12:12:19.342 I/dalvikvm(18665): at android.os.Looper.loop(Looper.java:137)
07-18 12:12:19.342 I/dalvikvm(18665): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-18 12:12:19.342 I/dalvikvm(18665): at java.lang.reflect.Method.invokeNative(Native Method)
07-18 12:12:19.342 I/dalvikvm(18665): at java.lang.reflect.Method.invoke(Method.java:511)
07-18 12:12:19.342 I/dalvikvm(18665): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-18 12:12:19.342 I/dalvikvm(18665): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-18 12:12:19.342 I/dalvikvm(18665): at dalvik.system.NativeStart.main(Native Method)
07-18 12:12:19.342 I/dalvikvm(18665):
Unhandled Exception:
Android.Views.InflateException: Binary XML file line #24: Error inflating class <unknown>
07-18 12:12:24.902 I/dalvikvm-heap(18665): Clamp target GC heap from 68.644MB to 64.000MB
07-18 12:12:24.902 D/dalvikvm(18665): GC_FOR_ALLOC freed 5K, 1% free 65105K/65543K, paused 377ms
07-18 12:12:24.902 I/dalvikvm-heap(18665): Forcing collection of SoftReferences for 1402-byte allocation
07-18 12:12:25.242 I/dalvikvm-heap(18665): Clamp target GC heap from 68.644MB to 64.000MB
07-18 12:12:25.242 D/dalvikvm(18665): GC_BEFORE_OOM freed 0K, 1% free 65105K/65543K, paused 345ms
07-18 12:12:25.242 E/dalvikvm-heap(18665): Out of memory on a 1402-byte allocation.
07-18 12:12:25.242 I/dalvikvm(18665): "main" prio=5 tid=1 RUNNABLE
07-18 12:12:25.242 I/dalvikvm(18665): | group="main" sCount=0 dsCount=0 obj=0x40a45460 self=0xb068a0
07-18 12:12:25.242 I/dalvikvm(18665): | sysTid=18665 nice=0 sched=0/0 cgrp=default handle=1074517128
07-18 12:12:25.242 I/dalvikvm(18665): | schedstat=( 72950645000 19154453000 88901 ) utm=6504 stm=791 core=0
07-18 12:12:25.242 I/dalvikvm(18665): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:~94)
07-18 12:12:25.242 I/dalvikvm(18665): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:124)
07-18 12:12:25.242 I/dalvikvm(18665): at java.lang.StringBuffer.append(StringBuffer.java:278)
07-18 12:12:25.242 I/dalvikvm(18665): at java.io.StringWriter.write(StringWriter.java:123)
07-18 12:12:25.242 I/dalvikvm(18665): at java.io.PrintWriter.doWrite(PrintWriter.java:623)
07-18 12:12:25.242 I/dalvikvm(18665): at java.io.PrintWriter.write(PrintWriter.java:601)
07-18 12:12:25.242 I/dalvikvm(18665): at java.io.PrintWriter.write(PrintWriter.java:579)
07-18 12:12:25.242 I/dalvikvm(18665): at java.io.PrintWriter.write(PrintWriter.java:660)
07-18 12:12:25.242 I/dalvikvm(18665): at java.io.PrintWriter.append(PrintWriter.java:722)
07-18 12:12:25.242 I/dalvikvm(18665): at java.io.PrintWriter.append(PrintWriter.java:691)
07-18 12:12:25.252 I/dalvikvm(18665): at java.io.PrintWriter.append(PrintWriter.java:31)
07-18 12:12:25.252 I/dalvikvm(18665): at java.lang.Throwable.printStackTrace(Throwable.java:329)
07-18 12:12:25.252 I/dalvikvm(18665): at java.lang.Throwable.printStackTrace(Throwable.java:305)
07-18 12:12:25.252 I/dalvikvm(18665): at myFirstApp.android.activities.SplashScreenActivity.n_onCreate(Native Method)
07-18 12:12:25.252 I/dalvikvm(18665): at myFirstApp.android.activities.SplashScreenActivity.onCreate(SplashScreenActivity.java:30)
07-18 12:12:25.252 I/dalvikvm(18665): at android.app.Activity.performCreate(Activity.java:4465)
07-18 12:12:25.252 I/dalvikvm(18665): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-18 12:12:25.252 I/dalvikvm(18665): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
07-18 12:12:25.252 I/dalvikvm(18665): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-18 12:12:25.252 I/dalvikvm(18665): at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-18 12:12:25.252 I/dalvikvm(18665): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-18 12:12:25.252 I/dalvikvm(18665): at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 12:12:25.252 I/dalvikvm(18665): at android.os.Looper.loop(Looper.java:137)
07-18 12:12:25.252 I/dalvikvm(18665): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-18 12:12:25.252 I/dalvikvm(18665): at java.lang.reflect.Method.invokeNative(Native Method)
07-18 12:12:25.252 I/dalvikvm(18665): at java.lang.reflect.Method.invoke(Method.java:511)
07-18 12:12:25.252 I/dalvikvm(18665): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-18 12:12:25.252 I/dalvikvm(18665): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-18 12:12:25.252 I/dalvikvm(18665): at dalvik.system.NativeStart.main(Native Method)
07-18 12:12:25.252 I/dalvikvm(18665):
07-18 12:12:26.042 I/dalvikvm-heap(18665): Clamp target GC heap from 68.654MB to 64.000MB
07-18 12:12:26.042 D/dalvikvm(18665): GC_FOR_ALLOC freed 4K, 1% free 65114K/65543K, paused 395ms
07-18 12:12:26.042 I/dalvikvm-heap(18665): Forcing collection of SoftReferences for 1126-byte allocation
07-18 12:12:26.392 I/dalvikvm-heap(18665): Clamp target GC heap from 68.654MB to 64.000MB
07-18 12:12:26.392 D/dalvikvm(18665): GC_BEFORE_OOM freed 0K, 1% free 65114K/65543K, paused 344ms
07-18 12:12:26.392 E/dalvikvm-heap(18665): Out of memory on a 1126-byte allocation.
07-18 12:12:26.392 I/dalvikvm(18665): "main" prio=5 tid=1 RUNNABLE
07-18 12:12:26.392 I/dalvikvm(18665): | group="main" sCount=0 dsCount=0 obj=0x40a45460 self=0xb068a0
07-18 12:12:26.392 I/dalvikvm(18665): | sysTid=18665 nice=0 sched=0/0 cgrp=default handle=1074517128
07-18 12:12:26.392 I/dalvikvm(18665): | schedstat=( 73695992000 19195168000 89137 ) utm=6574 stm=795 core=0
07-18 12:12:26.392 I/dalvikvm(18665): at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:~94)
07-18 12:12:26.392 I/dalvikvm(18665): at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:124)
07-18 12:12:26.392 I/dalvikvm(18665): at java.lang.StringBuffer.append(StringBuffer.java:278)
07-18 12:12:26.392 I/dalvikvm(18665): at java.io.StringWriter.write(StringWriter.java:123)
07-18 12:12:26.392 I/dalvikvm(18665): at java.io.PrintWriter.doWrite(PrintWriter.java:623)
07-18 12:12:26.392 I/dalvikvm(18665): at java.io.PrintWriter.write(PrintWriter.java:601)
07-18 12:12:26.392 I/dalvikvm(18665): at java.io.PrintWriter.write(PrintWriter.java:579)
07-18 12:12:26.392 I/dalvikvm(18665): at java.io.PrintWriter.write(PrintWriter.java:660)
07-18 12:12:26.392 I/dalvikvm(18665): at java.io.PrintWriter.append(PrintWriter.java:722)
07-18 12:12:26.392 I/dalvikvm(18665): at java.io.PrintWriter.append(PrintWriter.java:691)
07-18 12:12:26.392 I/dalvikvm(18665): at java.io.PrintWriter.append(PrintWriter.java:31)
07-18 12:12:26.392 I/dalvikvm(18665): at java.lang.Throwable.printStackTrace(Throwable.java:329)
07-18 12:12:26.392 I/dalvikvm(18665): at java.lang.Throwable.printStackTrace(Throwable.java:305)
07-18 12:12:26.392 I/dalvikvm(18665): at myFirstApp.android.activities.SplashScreenActivity.n_onCreate(Native Method)
07-18 12:12:26.392 I/dalvikvm(18665): at myFirstApp.android.activities.SplashScreenActivity.onCreate(SplashScreenActivity.java:30)
07-18 12:12:26.392 I/dalvikvm(18665): at android.app.Activity.performCreate(Activity.java:4465)
07-18 12:12:26.392 I/dalvikvm(18665): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-18 12:12:26.392 I/dalvikvm(18665): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
07-18 12:12:26.392 I/dalvikvm(18665): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-18 12:12:26.392 I/dalvikvm(18665): at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-18 12:12:26.392 I/dalvikvm(18665): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-18 12:12:26.392 I/dalvikvm(18665): at android.os.Handler.dispatchMessage(Handler.java:99)
07-18 12:12:26.392 I/dalvikvm(18665): at android.os.Looper.loop(Looper.java:137)
07-18 12:12:26.392 I/dalvikvm(18665): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-18 12:12:26.392 I/dalvikvm(18665): at java.lang.reflect.Method.invokeNative(Native Method)
07-18 12:12:26.392 I/dalvikvm(18665): at java.lang.reflect.Method.invoke(Method.java:511)
07-18 12:12:26.392 I/dalvikvm(18665): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-18 12:12:26.392 I/dalvikvm(18665): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-18 12:12:26.392 I/dalvikvm(18665): at dalvik.system.NativeStart.main(Native Method)
07-18 12:12:26.392 I/dalvikvm(18665):
Unhandled Exception:
Java.Lang.OutOfMemoryError:
Additional information
The image is full screen and is the perfect size for this device (I mean that we don't want to shrink it). 1024x720, 24 bits, not Alpha and it takes 487KB on my disk, but obviously, when Android loads it, it seems to be around 10 MB.
I'm running the code on a Nabi2 tablet, model : NABI2-NV7A which is running Android version 4.0.4 along with Kernel version 3.1.10-00275-g3a4f8c1.
Also note that in Visual Studio in my Application Properties, I am targetting those Android versions:
OK, I found a way to do this without throwing these errors.
Instead of creating a Layout with the Splash Screen, I created a theme, since in your case it is simply an image anyways:
styles.xml
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="SplashTheme" parent="#android:style/Theme.NoTitleBar">
<item name="android:background">#drawable/kitten</item>
</style>
</resources>
Then I created an Activity like this:
using Android.App;
using Android.Content;
using Android.OS;
namespace SplashScreenSample
{
[Activity(Label = "Splushy Splushy", MainLauncher = true, Theme = "#style/SplashTheme")]
public class SplashActivity : Activity
{
protected override void OnCreate(Bundle b)
{
base.OnCreate(b);
StartNextActivity();
}
private void StartNextActivity()
{
var intent = new Intent(this, typeof(SplashActivity));
intent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearWhenTaskReset);
StartActivity(intent);
Finish();
}
}
}
I tried running this on my phone for 10 minutes or so, without any crash with an image of 1600x1200 of a nice kitten.
I found another solution that helped, but never as much as Cheesebaron's solution.
In both cases, it end up crashing.
Cheesebaron's solution crashes after : 14 minutes
Mine crashes after 3 minutes 28 sec.
Since I'm looping intensively to push the device to its limit, Cheesebaron's solution is surely viable.
In my case, instead of setting android:background="#drawable/splash", I removed that entry and used a private Bitmap field in my activity which I then load and pass it to the background drawable.
private Bitmap _bitmapRef;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var view = FindViewById<LinearLayout>(Resource.Id.SplashScreenView);
_bitmapRef = BitmapFactory.DecodeResource(Resources, Resource.Drawable.splash, new BitmapFactory.Options
{
InPurgeable = true,
InInputShareable = true
});
view.SetBackgroundDrawable(new BitmapDrawable(Resources, _bitmapRef));
StartNextActivity();
}
Then, on the OnDestroy call, I override it to explicitly recycle the bitmap.
protected override void OnDestroy()
{
base.OnDestroy();
if (null != _bitmapRef && !_bitmapRef.IsRecycled)
{
_bitmapRef.Recycle();
_bitmapRef = null;
}
}
It seems to me like if Android have problems when the Bitmap is created at the Activity level.
I have another activities in which I load bitmaps in a list object to display them on screen. The list object is at the Activity level and the bitmaps are inside the list.
In that case, the memory seems to be handled properly when I use the above solution. I don't even have to call recycle on the bitmaps inside the list.
But for the SplashScreen, that solution doesn't seems to be enough.

Which ports does android use?

I have UnknownHostExeption, when i am using proxy. My App works finy in networks without proxy or with some proxies( not everyone).
I am aware that I need to setup proxy setings for networks with them
for device: wify settings - advance - wifi proxy
emulator: wireless networks - mobile networks - access points - telkia - proxy|port.
I wish to know which essential options I have to ask admins to unlock for stable network comunications.
07-18 08:51:26.780: W/System.err(302): java.net.UnknownHostException: mirkvartir.ua
07-18 08:51:26.780: W/System.err(302): at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
07-18 08:51:26.780: W/System.err(302): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
07-18 08:51:26.780: W/System.err(302): at java.net.InetAddress.getAllByName(InetAddress.java:242)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
07-18 08:51:26.780: W/System.err(302): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
07-18 08:51:26.780: W/System.err(302): at ua.mirkvartir.android.frontend.adapter.JSONParser.getJSONFromUrl(JSONParser.java:98)
07-18 08:51:26.780: W/System.err(302): at ua.mirkvartir.android.frontend.adapter.UserFunctions.loginUser(UserFunctions.java:76)
07-18 08:51:26.787: W/System.err(302): at ua.mirkvartir.android.frontend.LoginActivity$Login.doInBackground(LoginActivity.java:185)
07-18 08:51:26.787: W/System.err(302): at ua.mirkvartir.android.frontend.LoginActivity$Login.doInBackground(LoginActivity.java:1)
07-18 08:51:26.787: W/System.err(302): at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-18 08:51:26.787: W/System.err(302): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-18 08:51:26.787: W/System.err(302): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-18 08:51:26.787: W/System.err(302): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
07-18 08:51:26.787: W/System.err(302): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
07-18 08:51:26.787: W/System.err(302): at java.lang.Thread.run(Thread.java:1096)
Answer is, you cannot tell in general. This is not Android-specific, but depends on your App. You're free to choose the ports it communicates over. Usually, 80 and 443 shouldn't be blocked (http / https) - everything else depends on your App.
What services do you use? If you never specified a port explicitly, they might imply one.

loading my library

There is my used project: http://code.google.com/p/droidreader/
when I try to run my project, I got a problem loading my library "pdfrender"
Here is the line causing the problem: System.loadLibrary("pdfrender");
In my project, I have a floader named jni and contain the library pdfrender.c
Here is my logcat:
02-28 10:57:55.241: E/AndroidRuntime(596): java.lang.ExceptionInInitializerError
02-28 10:57:55.241: E/AndroidRuntime(596): at de.hilses.droidreader.DroidReaderActivity.onCreate(DroidReaderActivity.java:108)
02-28 10:57:55.241: E/AndroidRuntime(596): at android.app.Activity.performCreate(Activity.java:4465)
02-28 10:57:55.241: E/AndroidRuntime(596): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
02-28 10:57:55.241: E/AndroidRuntime(596): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
02-28 10:57:55.241: E/AndroidRuntime(596): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
02-28 10:57:55.241: E/AndroidRuntime(596): at android.app.ActivityThread.access$600(ActivityThread.java:123)
02-28 10:57:55.241: E/AndroidRuntime(596): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
02-28 10:57:55.241: E/AndroidRuntime(596): at android.os.Handler.dispatchMessage(Handler.java:99)
02-28 10:57:55.241: E/AndroidRuntime(596): at android.os.Looper.loop(Looper.java:137)
02-28 10:57:55.241: E/AndroidRuntime(596): at android.app.ActivityThread.main(ActivityThread.java:4424)
02-28 10:57:55.241: E/AndroidRuntime(596): at java.lang.reflect.Method.invokeNative(Native Method)
02-28 10:57:55.241: E/AndroidRuntime(596): at java.lang.reflect.Method.invoke(Method.java:511)
02-28 10:57:55.241: E/AndroidRuntime(596): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
02-28 10:57:55.241: E/AndroidRuntime(596): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
02-28 10:57:55.241: E/AndroidRuntime(596): at dalvik.system.NativeStart.main(Native Method)
02-28 10:57:55.241: E/AndroidRuntime(596): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load pdfrender: findLibrary returned null
02-28 10:57:55.241: E/AndroidRuntime(596): at java.lang.Runtime.loadLibrary(Runtime.java:365)
02-28 10:57:55.241: E/AndroidRuntime(596): at java.lang.System.loadLibrary(System.java:535)
02-28 10:57:55.241: E/AndroidRuntime(596): at de.hilses.droidreader.PdfRender.<clinit>(PdfRender.java:111)
02-28 10:57:55.241: E/AndroidRuntime(596): ... 15 more
finally i found the solution we have to install ndk-android and cygwin. then we are able to build .so from .c file.
For more explanation you can see this, it helped me very much:
http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/
> Couldn't load (library) pdfrender
If you build with eclipse make shure that the library pdfrender in the build-path is marked as Exported (checkbox before lib is set).
Then it should be included into the build apk-file

AdMob After Ad receive - IOException connecting to ad url

i have an android app that need to show ads by AdMob.
here's my Log:
07-18 01:55:53.116: INFO/Ads(8682): adRequestUrlHtml: <html><head><script src="http://www.gstatic.com/afma/sdk-core-v40.js"></script><script>AFMA_buildAdURL({"preqs":0,"u_sd":1.5,"slotname":"**************","u_w":320,"msid":"com.paladin.hilula","cap":"m","adtest":"on","js":"afma-sdk-a-v4.1.0","isu":"*********************************","format":"320x50_mb","net":"ed","app_name":"1.android.com.paladin.hilula","hl":"hd","u_h":569,"testing":1,"u_audio":1,"u_so":"p"});</script></head><body></body></html>
07-18 01:55:54.187: INFO/Ads(8682): Received ad url: <"url": "http://r.admob.com:80/ad_source.php?preqs=0&u_sd=1.5&slotname=**************&u_w=320&msid=com.paladin.hilula&cap=m&adtest=on&js=afma-sdk-a-v4.1.0&isu=*************************&format=320x50_mb&net=ed&app_name=1.android.com.paladin.hilula&hl=hd&u_h=569&testing=1&u_audio=1&u_so=p&output=html&region=mobile_app&u_tz=-180&ex=1&client_sdk=1", "afmaNotifyDt": "null">
07-18 01:56:15.288: WARN/Ads(8682): IOException connecting to ad url.
07-18 01:56:15.288: WARN/Ads(8682): java.net.SocketTimeoutException: Connection timed out
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.platform.OSNetworkSystem.connect(Native Method)
07-18 01:56:15.288: WARN/Ads(8682): at dalvik.system.BlockGuard$WrappedNetworkSystem.connect(BlockGuard.java:357)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:204)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.net.PlainSocketImpl.connect(PlainSocketImpl.java:437)
07-18 01:56:15.288: WARN/Ads(8682): at java.net.Socket.connect(Socket.java:983)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:75)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:48)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection$Address.connect(HttpConnection.java:322)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionPool.get(HttpConnectionPool.java:89)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.getHttpConnection(HttpURLConnectionImpl.java:285)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.makeConnection(HttpURLConnectionImpl.java:267)
07-18 01:56:15.288: WARN/Ads(8682): at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:205)
07-18 01:56:15.288: WARN/Ads(8682): at b.a(Unknown Source)
07-18 01:56:15.288: WARN/Ads(8682): at b.doInBackground(Unknown Source)
07-18 01:56:15.288: WARN/Ads(8682): at android.os.AsyncTask$2.call(AsyncTask.java:185)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
07-18 01:56:15.288: WARN/Ads(8682): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
07-18 01:56:15.288: WARN/Ads(8682): at java.lang.Thread.run(Thread.java:1019)
07-18 01:56:15.296: INFO/Ads(8682): onFailedToReceiveAd(A network error occurred.)
i get the URL but cant show it.
in manifest:
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation"/>
</application>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
in .java:
// Create the adView
AdView adView = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID);
// Lookup your LinearLayout assuming it’s been given
// the attribute android:id="#+id/mainLayout"
RelativeLayout layout = (RelativeLayout)findViewById(R.id.rlayout);
// Add the adView to it
layout.addView(adView);
// Initiate a generic request to load it with an ad
AdRequest r = new AdRequest();
r.setTesting(true);
r.addTestDevice("*****************************");
adView.loadAd(r);
The /etc/hosts file on your phone has aliased r.admob.com to 127.0.0.1. I had this occur when I used a flashed ROM on my phone -- the ROM defined a whole bunch of entries like that so I'd never get ads. Which was great until I was testing my own ad-enabled app :-)
Edit your /etc/hosts and take out that entry.
AdMob's server (like any high volume server) can take too long to respond sometimes. It is better that you design with failure like this as expected behavior.
If you think there is more to it than that. Post what you are seeing that makes you think something else may be going on.

Categories

Resources