1

This is my Manifest permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.LOCATION_HARDWARE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="nl.hgrams.passenger.C2D_MESSAGE" />

This is my Activity:

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    ButterKnife.inject(this);
    mSearchFragment = new PSSearchFragment();
    mMapFragment = new PSMapFragment();

    FragmentTransaction transaction = getFragmentManager().beginTransaction();
    transaction.add(R.id.fragmentContainer, mSearchFragment, TAG_SEARCH);
    transaction.add(R.id.fragmentContainer, mMapFragment, TAG_MAP);
    transaction.hide(mMapFragment);
    transaction.commit();

    mCurrentFragment = mSearchFragment;
}

Which has a FrameLayout where I load Fragments:

    <FrameLayout
    android:id="@+id/fragmentContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

This is my map Fragment:

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.MapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>

<LinearLayout
    android:id="@+id/display_button"
    android:visibility="gone"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_gravity="bottom|center_horizontal"
    android:background="#88FFFFFF">

    <Button
        android:id="@+id/display_markers"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/text_medium_padding"
        android:background="@drawable/rounded_button_green"
        android:text="@string/display_location_markers"
        android:textColor="@color/white" />
</LinearLayout>


<TextView
    android:id="@+id/display_message"
    android:visibility="gone"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center_horizontal"
    android:padding="10dp"
    android:layout_alignParentBottom="true"
    android:layout_gravity="bottom|center_horizontal"
    android:text="@string/long.press.tooltip"
    android:background="#88FFFFFF">
    </TextView>


<nl.hgrams.passenger.ui.AnimatedImageView
    android:id="@+id/loader_container"
    android:layout_width="@dimen/loader_size"
    android:layout_height="@dimen/loader_size"
    android:layout_centerInParent="true"
    android:background="@drawable/loading_animation"
    android:visibility="invisible" />

This is my OnCreateView for my mapFragment:

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        try{
            View view = inflater.inflate(R.layout.fragment_map, container, false);
            ButterKnife.inject(this, view);
            if(!PSLocationCenter.getInstance().mLocationClient.isConnected()) {
                PSLocationCenter.getInstance().startLocationClient();
            }
            gson = new GsonBuilder()
                    .setExclusionStrategies(new ExclusionStrategy() {
                        @Override
                        public boolean shouldSkipField(FieldAttributes f) {
                            return f.getDeclaringClass().equals(RealmObject.class);
                        }

                        @Override
                        public boolean shouldSkipClass(Class<?> clazz) {
                            return false;
                        }
                    })
                    .create();
            return view;
        }catch (Exception e){
            Log.i("","errror in map fragment" + e.getMessage());
            getActivity().startActivity(new Intent(getActivity(), PSSearchActivity.class));
            getActivity().finish();
            return null;
        }

    }

I get the following error, when trying to open activity:

 Asset path '/system/framework/com.android.media.remotedisplay.jar' does not exist or contains no resources.
 Asset path '/system/framework/com.android.location.provider.jar' does not exist or contains no resources.

I tried using:

android:name="com.google.android.gms.maps.SupportMapFragment"

instead of:

android:name="com.google.android.gms.maps.MapFragment"

But then it crashes at:

  View view = inflater.inflate(R.layout.fragment_map, container, false); 

Error: Binary XML file line #8: Error inflating class fragment

Enters the try catch and doesn't show anything. Any ideea what I'm doing wrong? I update everything I could in the SDK Tool manager, even updated google api. Tried using a older version of play-services, tried going back to build tools 21.0.1 but same thing :(

Build.gradle file:

android {
    compileSdkVersion 22
    buildToolsVersion '22.0.1'
    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 291
        versionName '1.5.0'
        multiDexEnabled true
    }
    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "2g"
    }
    packagingOptions {
        exclude 'META-INF/services/javax.annotation.processing.Processor'
    }
    buildTypes {
        release {
            ext.enableCrashlytics=true
            ext.betaDistributionReleaseNotesFilePath="/Users/gopublic/bamboo-home/xml-data/build-dir/131073/PAS-PAD-VRANDROID/changelog.txt"
            ext.betaDistributionEmails="alin.rosu@100grams.nl, pedro.amanhui@100grams.nl, 100gramstest@gmail.com"
            ext.betaDistributionGroupAliases="passenger-android-beta"

        }

        debug{
            ext.enableCrashlytics=true
            ext.betaDistributionEmails="alin.rosu@100grams.nl, pedro.amanhui@100grams.nl, 100gramstest@gmail.com"
            ext.betaDistributionReleaseNotesFilePath="/Users/gopublic/bamboo-home/xml-data/build-dir/131073/PAS-PAD-VRANDROID/changelog.txt"
            ext.betaDistributionGroupAliases="passenger-android-beta"

        }
    }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.+'
compile 'com.android.support:multidex:1.0.0'
compile 'com.google.code.gson:gson:2+'
compile 'com.android.support:cardview-v7:22.0.+'
compile 'com.android.support:recyclerview-v7:22.0.+'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.jakewharton:butterknife:4.0.+'
compile 'com.squareup.okhttp:okhttp:2.0.0+'
compile 'com.google.android.gms:play-services:+'
compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
compile 'com.tonicartos:stickygridheaders:1.0.1@jar'
compile 'com.prolificinteractive:parallaxpager:0.8.0'
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/gcm.jar')
compile files('libs/okhttp-urlconnection-2.0.0.jar')
compile project(':libraries:facebook')
compile 'com.edmodo:cropper:1.0.1'
compile 'com.squareup.picasso:picasso:2.3.3'
compile 'com.makeramen:roundedimageview:1.3.0'
compile 'com.androidplot:androidplot-core:0.6.1'
compile 'com.google.maps.android:android-maps-utils:0.3+'
compile 'com.instabug.library:instabugsupport:1+'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'io.realm:realm-android:0.80.+'
compile('com.crashlytics.sdk.android:crashlytics:2.2.3@aar') {
    transitive = true;
}
compile files('libs/easyandroidanimationslibrary-v0.5.jar')
}
rosu alin
  • 5,674
  • 11
  • 69
  • 150

1 Answers1

1

I had faced same issue .Try this compileSdkVersion 21 buildToolsVersion '21.1.2' Instead 22.0.1. Version 22.0.1 is not purely stable

IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
  • 1
    Tried it with 21.1.2 Same problem. Tried even to force it to use a older version of play services and no luck. Have no more ideas. Waiting for a answer, and in the meanwhile, started to convert my code to use 2 activities instead of 1 activity with 2 fragments, cause the map works in activities. There is a problem there with supportMapFragment or MapFragment. Have no idea what though, not yet – rosu alin Jul 17 '15 at 13:58
  • Did you used import android.support.v4.app.FragmentActivity ? – IntelliJ Amiya Jul 17 '15 at 14:04
  • Use supportMapFragment instead MapFragment (I know you already tried ) – IntelliJ Amiya Jul 17 '15 at 14:04
  • Use this compile 'com.google.android.gms:play-services:5.0.89' instead compile 'com.google.android.gms:play-services:+' – IntelliJ Amiya Jul 17 '15 at 14:05
  • 1
    I get this error: /Users/alinrosu/Workspace/passenger-android/passenger/src/main/res/values/colors.xml Error:(2) Attribute "theme" has already been defined Even if I don't have nothing with "theme" in my colors.xml file, wtf? – rosu alin Jul 17 '15 at 15:23