没有充分理由,Android应用程序在发布时不断崩溃

时间:2012-04-27 17:06:27

标签: android android-emulator titanium-mobile

我一直试图弄清楚这几天,但无济于事。我正在使用Titanium开发一个简单的Android应用程序,在iOS上运行得非常好。然而,当我在Android上启动它时,它永远不会启动。这是我的manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.tiki.signals" android:versionCode="1"
    android:versionName="1">
    <uses-sdk android:minSdkVersion="8" />

    <!-- TI_MANIFEST -->

    <application android:icon="@drawable/appicon"
        android:label="Signals" android:name="SignalsApplication"
        android:debuggable="false">

        <!-- TI_APPLICATION -->

        <activity android:name=".SignalsActivity"
            android:label="Signals" android:theme="@style/Theme.Titanium"
            android:configChanges="keyboardHidden|orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity 
        android:name="ti.modules.titanium.facebook.FBActivity"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"
    />

        <activity android:name="org.appcelerator.titanium.TiActivity"
            android:configChanges="keyboardHidden|orientation" />
        <activity android:name="org.appcelerator.titanium.TiTranslucentActivity"
            android:configChanges="keyboardHidden|orientation"
            android:theme="@android:style/Theme.Translucent" />
        <activity android:name="org.appcelerator.titanium.TiModalActivity"
            android:configChanges="keyboardHidden|orientation"
            android:theme="@android:style/Theme.Translucent" />
        <activity android:name="ti.modules.titanium.ui.TiTabActivity"
            android:configChanges="keyboardHidden|orientation" />
        <activity android:name="ti.modules.titanium.ui.android.TiPreferencesActivity" />

        <service android:name="org.appcelerator.titanium.analytics.TiAnalyticsService"
            android:exported="false" />
    </application>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
</manifest>

这是logcat:

I/ActivityManager(   81): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.tiki.signals/.SignalsActivity} from pid 176
D/PermissionCache(   35): checking android.permission.READ_FRAME_BUFFER for uid=1000 => granted (1163 us)
D/dalvikvm(   81): GC_FOR_ALLOC freed 842K, 14% free 11108K/12807K, paused 106ms
I/dalvikvm-heap(   81): Grow heap (frag case) to 12.385MB for 1536016-byte allocation
D/dalvikvm(   81): GC_FOR_ALLOC freed 1K, 13% free 12606K/14343K, paused 105ms
W/WindowManager(   81): Failure taking screenshot for (180x300) to layer 21005
I/ActivityManager(   81): Start proc com.tiki.signals for activity com.tiki.signals/.SignalsActivity: pid=457 uid=10040 gids={1015, 3003}
I/dalvikvm(  457): Turning on JNI app bug workarounds for target SDK version 8...
W/NetworkManagementSocketTagger(   81): setKernelCountSet(10040, 1) failed with errno -2
D/dalvikvm(   81): GC_CONCURRENT freed 13K, 13% free 12619K/14343K, paused 8ms+32ms
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
I/TiApplication(  457): (main) [0,0] checkpoint, app created.
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
D/dalvikvm(  457): GC_CONCURRENT freed 243K, 4% free 9294K/9607K, paused 7ms+6ms
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
I/TiApplication(  457): (main) [682,682] Titanium 1.8.2 (2012/02/23 17:46 59b3a90)
D/dalvikvm(  457): GC_CONCURRENT freed 422K, 5% free 9434K/9927K, paused 6ms+4ms
I/TiApplication(  457): (main) [254,936] Titanium Javascript runtime: v8
D/dalvikvm(  457): Trying to load lib /data/data/com.tiki.signals/lib/libstlport_shared.so 0x412a1e60
D/dalvikvm(  457): Added shared lib /data/data/com.tiki.signals/lib/libstlport_shared.so 0x412a1e60
D/dalvikvm(  457): No JNI_OnLoad found in /data/data/com.tiki.signals/lib/libstlport_shared.so 0x412a1e60, skipping init
D/dalvikvm(  457): Trying to load lib /data/data/com.tiki.signals/lib/libkroll-v8.so 0x412a1e60
I/TiRootActivity(  457): (main) [0,0] checkpoint, on root activity create, savedInstanceState: null
D/dalvikvm(  457): Added shared lib /data/data/com.tiki.signals/lib/libkroll-v8.so 0x412a1e60
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
E/TiApplication(  457): (KrollRuntimeThread) [3551,3551] APP PROXY: ti.modules.titanium.app.AppModule@41334e08
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
D/dalvikvm(  457): GC_CONCURRENT freed 349K, 5% free 9566K/10055K, paused 7ms+6ms
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
D/dalvikvm(  457): GC_FOR_ALLOC freed 452K, 7% free 9534K/10183K, paused 84ms
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
D/TiLocation(  457): (main) [2290,5841] preferredProvider property found [null]
D/TiLocation(  457): (main) [1,5842] accuracy property found [0]
E/TiLocationHelper(  457): (main) [31,5873] unable to register, provider is null
D/dalvikvm(  457): GC_FOR_ALLOC freed 105K, 7% free 9571K/10183K, paused 61ms
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
I/dalvikvm-heap(  457): Grow heap (frag case) to 10.878MB for 1536016-byte allocation
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
D/dalvikvm(  457): GC_CONCURRENT freed 1K, 6% free 11070K/11719K, paused 8ms+5ms
I/TiRootActivity(  457): (main) [0,0] checkpoint, on root activity resume. activity = com.tiki.signals.SignalsActivity@412aba88
V/PhoneStatusBar(  134): setLightsOn(true)
I/Process (   81): Sending signal. PID: 457 SIG: 3
I/dalvikvm(  457): threadid=3: reacting to signal 3
W/InputManagerService(   81): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@41434cb8 (uid=10013 pid=176)
I/dalvikvm(  457): Wrote stack traces to '/data/anr/traces.txt'
D/gralloc_goldfish(  457): Emulator without GPU emulation detected.
I/ActivityManager(   81): Displayed com.tiki.signals/.SignalsActivity: +9s553ms
W/NetworkManagementSocketTagger(   81): setKernelCountSet(10013, 0) failed with errno -2
D/ExchangeService(  355): Received deviceId from Email app: androidc259148960
D/ExchangeService(  355): Reconciling accounts...
D/dalvikvm(   81): GC_EXPLICIT freed 1712K, 23% free 11125K/14343K, paused 7ms+11ms
W/ThrottleService(   81): unable to find stats for iface rmnet0
W/TiAnalyticsSvc(  457): (Thread-65) [23787,23787] Analytics Service Started
I/TiAnalyticsSvc(  457): (Thread-65) [152,23939] Sending 2 analytics events.
W/TiAnalyticsSvc(  457): (Thread-65) [1072,25011] Stopping Analytics Service

这是我的tiapp.xml:

<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
    <property name="ti.android.runtime">v8</property>
    <property name="ti.android.threadstacksize" type="int">132768</property>
    <property name="ti.android.fastdev" type="bool">false</property>
    <sdk-version>1.8.2</sdk-version>
    <deployment-targets>
        <target device="mobileweb">false</target>
        <target device="iphone">true</target>
        <target device="ipad">true</target>
        <target device="android">true</target>
        <target device="blackberry">false</target>
    </deployment-targets>
    <id>com.tiki.signals</id>
    <name>Signals</name>
    <version>1.0</version>
    <publisher>Michael</publisher>
    <url>http://</url>
    <description>not specified</description>
    <copyright>2012 by meilers</copyright>
    <icon>appicon.png</icon>
    <persistent-wifi>false</persistent-wifi>
    <prerendered-icon>false</prerendered-icon>
    <statusbar-style>default</statusbar-style>
    <statusbar-hidden>false</statusbar-hidden>
    <fullscreen>false</fullscreen>
    <navbar-hidden>false</navbar-hidden>
    <analytics>true</analytics>
    <guid>49aefe11-b922-4f04-bffd-887ed59cb5d3</guid>
    <iphone>
        <orientations device="iphone">
            <orientation>Ti.UI.PORTRAIT</orientation>
        </orientations>
        <orientations device="ipad">
            <orientation>Ti.UI.PORTRAIT</orientation>
            <orientation>Ti.UI.UPSIDE_PORTRAIT</orientation>
            <orientation>Ti.UI.LANDSCAPE_LEFT</orientation>
            <orientation>Ti.UI.LANDSCAPE_RIGHT</orientation>
        </orientations>
    </iphone>
    <android xmlns:android="http://schemas.android.com/apk/res/android"/>
    <modules/>
</ti:app>

这里发生了什么?我没有在logcat中看到任何错误。虚拟机正在关闭,没有任何理由。请帮忙!

1 个答案:

答案 0 :(得分:2)

只要看一下logcat就会想到一个项目......没有足够的内存。你会看到内存自由下降到3%YIKES!通常尝试保持10%的免费或操作系统可能会进入分页适合和可能超时的一些功能。

禁用应用中的某些功能并观看模拟器下的内存。 最好的建议是将应用程序安装到实际的手机上,尽管仿真器应该能够提供真实世界的结果。我不依赖于模拟任何硬件设备。

这是一些转储内存使用的代码。您需要找出目标类是什么。 在操作系统开始挑选您的应用程序之前,较旧的手机只有16MB的新手机48MB。将代码放在Oncreate中。

 Runtime rt = Runtime.getRuntime();
 long maxMemory = rt.maxMemory();
 Log.v("onCreate", "maxMemory:>>>>>" + Long.toString(maxMemory));   //max available memory to use

 ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
 int memoryClass = am.getMemoryClass();
 Log.v("onCreate", "memoryClass:>>>>" + Integer.toString(memoryClass));  //max available you should use to keep from getting bumped off

 printl("PGM MEM FREE MB", GetInternalMemAvail());
 printl("INTERNAL STORAGE FREE MEMORY BYTES",getmem());
 printl("INTERNAL TOTAL MEMORY BYTES",TotalMemory());
 printl("SD MEM FREE MB",GetSDMemAvail());
 printl("SD MEM GB",getAvailableSpaceInGB());

 private static void printl(String printstring,long x)
 {
  String temp;
  temp=String.format(" %d",x);
  Log.e(printstring,temp);  
 }