Tuesday, November 17, 2015

attempt to migrate DAT android to use AppCompat


migration worked, but getting crashes when navigating up from child activities.




tried to migrate DAT to use AppCompat.
crashing when navigating up using the toolbar (intent extras do not seem to be reserved)



https://github.com/codepath/android_guides/wiki/Migrating-to-the-AppCompat-Library


    compile 'com.android.support:appcompat-v7:23.1.1'



E/AndroidRuntime(23857): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.asa2fly.datandroid/com.asa2fly.datandroid.MainActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

-    <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">





##################################################
# search
##################################################


http://stackoverflow.com/questions/27049294/searchview-doesnt-work-since-app-compat

    <item android:id="@+id/menu_item_search"
        android:title="@string/search"
        android:icon="@android:drawable/ic_menu_search"
        app:showAsAction="always"
        app:actionViewClass="android.widget.SearchView"
        />

N.B. the app/android namespaces. since we're using appcompat we need to use app: in some cases.

imports in SFA
package com.asa2fly.datandroid;
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.SearchView;
import android.view.Menu;
import android.view.MenuItem;



##################################################
# crash
##################################################
E/AndroidRuntime(10619): FATAL EXCEPTION: main
E/AndroidRuntime(10619): Process: com.asa2fly.datandroid, PID: 10619
E/AndroidRuntime(10619): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
E/AndroidRuntime(10619): at com.asa2fly.datandroid.SearchHitListFragment.onLoadFinished(SearchHitListFragment.java:96)
E/AndroidRuntime(10619): at com.asa2fly.datandroid.SearchHitListFragment.onLoadFinished(SearchHitListFragment.java:27)
E/AndroidRuntime(10619): at android.support.v4.app.LoaderManagerImpl$LoaderInfo.callOnLoadFinished(LoaderManager.java:476)
E/AndroidRuntime(10619): at android.support.v4.app.LoaderManagerImpl$LoaderInfo.onLoadComplete(LoaderManager.java:444)
E/AndroidRuntime(10619): at android.support.v4.content.Loader.deliverResult(Loader.java:126)
E/AndroidRuntime(10619): at com.asa2fly.datandroid.SQLiteCursorLoader.deliverResult(SQLiteCursorLoader.java:32)
E/AndroidRuntime(10619): at com.asa2fly.datandroid.SQLiteCursorLoader.deliverResult(SQLiteCursorLoader.java:7)
E/AndroidRuntime(10619): at android.support.v4.content.AsyncTaskLoader.dispatchOnLoadComplete(AsyncTaskLoader.java:249)
E/AndroidRuntime(10619): at android.support.v4.content.AsyncTaskLoader$LoadTask.onPostExecute(AsyncTaskLoader.java:77)
E/AndroidRuntime(10619): at android.support.v4.content.ModernAsyncTask.finish(ModernAsyncTask.java:466)
E/AndroidRuntime(10619): at android.support.v4.content.ModernAsyncTask.access$400(ModernAsyncTask.java:48)
E/AndroidRuntime(10619): at android.support.v4.content.ModernAsyncTask$InternalHandler.handleMessage(ModernAsyncTask.java:483)
E/AndroidRuntime(10619): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(10619): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(10619): at android.app.ActivityThread.main(ActivityThread.java:5254)
E/AndroidRuntime(10619): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(10619): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(10619): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)

E/AndroidRuntime(10619): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)





Sunday, November 8, 2015

enable the gradle daemon



This build could be faster, please consider using the Gradle Daemon: http://gradle.org/docs/2.4/userguide/gradle_daemon.html



[smr@smr ~]$ touch ~/.gradle/gradle.properties && echo "org.gradle.daemon=true" >> ~/.gradle/gradle.properties

https://docs.gradle.org/2.4/userguide/gradle_daemon.html