這是我的清單許可權:
這是我的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;
}
它有一個 FrameLayout,其中我裝入 Fragments:
android:id="@+id/fragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
這是我的地圖 fragment:
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
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">
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"/>
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">
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"/>
這是我的OnCreateView,用於我的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;
}
}
嘗試打開 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.
我嘗試使用:android:name="com.google.android.gms.maps.SupportMapFragment"
替代:android:name="com.google.android.gms.maps.MapFragment"
但隨後它崩潰了:View view = inflater.inflate(R.layout.fragment_map, container, false);
錯誤:二進位XML文件行 #8: 打開類 fragment 時出錯
輸入嘗試捕捉,但不顯示任何內容。 任何我所做錯誤的ideea? 我更新了SDK工具管理器中的所有內容,甚至更新了 google api 。 嘗試使用舊版本的play服務,嘗試回到構建工具 21.0.1但同樣的事情:(
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')
}