Карта не отображается. Показаны только линии сетки
Я использую Baidu Map (SDK Version: 4.5.2), но они на карте не отображаются. Вместо этого отображаются только линии сетки.
Код:
public class MainApp extends MultiDexApplication {
@Override
public void onCreate() {
super.onCreate();
SDKInitializer.initialize(this);
}
}
BaiduMapActivity
class: (Этот код на Kotlin. Если вам нужен Java-эквивалент этого кода, пожалуйста, оставьте комментарий ниже.)
class BaiduMapActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_baidu_map)
}
override fun onResume() {
super.onResume()
bmapView.onResume()
}
}
файл build.gradle:
buildscript {
ext.kotlinVersion = '1.2.10'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
//noinspection GradleDynamicVersion
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
//For green dao
apply plugin: 'org.greenrobot.greendao'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://jitpack.io" }
jcenter()
}
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.0'
}
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.emerson.oversight"
minSdkVersion 16
targetSdkVersion 27
versionCode 6
versionName "1.6.2"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dataBinding {
enabled = true
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
disable 'MissingTranslation'
}
buildTypes {
release {
lintOptions {
disable 'MissingTranslation'
}
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
kapt { generateStubs = true }
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
transitive = true
}
//AppCompat v7 support library
compile 'com.android.support:appcompat-v7:27.0.2'
//AppCompat v4 support library
compile 'com.android.support:support-v4:27.0.2'
//Support design
compile 'com.android.support:design:27.0.2'
//Google Maps
compile 'com.google.android.gms:play-services-maps:11.8.0'
//Retrofit - for making REST API calls
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
//For Runtime permissions
compile 'com.karumi:dexter:4.2.0'
//To set custom fonts
compile 'uk.co.chrisjenx:calligraphy:2.2.0'
//Attaches bullets to viewpager
compile 'com.robohorse.pagerbullet:pagerbullet:1.0.8'
//Expandable recycler view
compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
//For Graph
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
//Date time
compile 'com.wdullaer:materialdatetimepicker:3.2.1'
compile 'com.android.support:recyclerview-v7:27.0.2'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support:support-annotations:27.0.2'
androidTestCompile 'com.android.support.test:runner:1.0.1'
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:gridlayout-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'jp.wasabeef:recyclerview-animators:2.2.6'
// compile 'com.ncornette.cache:okcache-control:1.1.1'
compile 'org.greenrobot:greendao:3.2.2'
compile 'net.danlew:android.joda:2.9.9'
compile 'com.github.barteksc:android-pdf-viewer:3.0.0-beta.3'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'org.jetbrains.anko:anko-common:0.8.3'
compile 'me.dm7.barcodescanner:zbar:1.9.8'
compile 'io.reactivex:rxjava:1.2.0'
compile 'com.squareup:android-times-square:1.6.5@aar'
// notice that the compiler version must be the same than our gradle version
kapt 'com.android.databinding:compiler:3.2.0-alpha05'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
}
}
apply plugin: 'kotlin-android-extensions'
Журналы:
03-27 23:44:51.059 7163-7163/com.emerson.oversight D/ViewRootImpl@ebc9b08[BaiduMapActivity]: ThreadedRenderer.create() translucent=true
03-27 23:44:51.062 7163-7163/com.emerson.oversight D/InputTransport: Input channel constructed: fd=113
03-27 23:44:51.062 7163-7163/com.emerson.oversight D/ViewRootImpl@ebc9b08[BaiduMapActivity]: setView = DecorView@dbaa2a1[BaiduMapActivity] touchMode=true
03-27 23:44:51.074 7163-7163/com.emerson.oversight I/SemDesktopModeManager: registerListener: android.view.ViewRootImpl$3@1965e9e
03-27 23:44:51.076 7163-7163/com.emerson.oversight D/ViewRootImpl@a0e9d7f[BaiduMapActivity]: ThreadedRenderer.create() translucent=false
03-27 23:44:51.078 7163-7163/com.emerson.oversight D/InputTransport: Input channel constructed: fd=115
03-27 23:44:51.078 7163-7163/com.emerson.oversight D/ViewRootImpl@a0e9d7f[BaiduMapActivity]: setView = DecorView@6f71595[BaiduMapActivity] touchMode=true
03-27 23:44:51.079 7163-7163/com.emerson.oversight D/ViewRootImpl@52ebfdf[Toast]: MSG_RESIZED_REPORT: frame=Rect(318, 2414 - 1122, 2568) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
03-27 23:44:51.102 7163-7163/com.emerson.oversight D/ViewRootImpl@ebc9b08[BaiduMapActivity]: dispatchAttachedToWindow
03-27 23:44:51.127 7163-7163/com.emerson.oversight D/ViewRootImpl@ebc9b08[BaiduMapActivity]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[37,1235][1403,1641] result=0x27 surface={isValid=true 547931812352} surfaceGenerationChanged=true
mHardwareRenderer.initialize() mSurface={isValid=true 547931812352} hwInitialized=true
03-27 23:44:51.135 7163-7163/com.emerson.oversight D/ViewRootImpl@a0e9d7f[BaiduMapActivity]: dispatchAttachedToWindow
03-27 23:44:51.160 7163-7163/com.emerson.oversight D/ViewRootImpl@a0e9d7f[BaiduMapActivity]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,0][1440,2960] result=0x27 surface={isValid=true 547759640576} surfaceGenerationChanged=true
mHardwareRenderer.initialize() mSurface={isValid=true 547759640576} hwInitialized=true
03-27 23:44:51.174 7163-7163/com.emerson.oversight D/SurfaceView: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,393][1440,2792] result=0x7 surface={Surface(name=null)/@0x479929b isValid=true 547759644160}
03-27 23:44:51.221 7163-7163/com.emerson.oversight D/ViewRootImpl@ebc9b08[BaiduMapActivity]: MSG_WINDOW_FOCUS_CHANGED 1
mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 547931812352}
03-27 23:44:51.233 7163-7163/com.emerson.oversight D/ViewRootImpl@a0e9d7f[BaiduMapActivity]: Relayout returned: oldFrame=[0,0][1440,2960] newFrame=[0,0][1440,2960] result=0x1 surface={isValid=true 547759640576} surfaceGenerationChanged=false
03-27 23:44:51.237 7163-7163/com.emerson.oversight D/SurfaceView: Relayout returned: oldFrame=[0,393][1440,2792] newFrame=[0,393][1440,2792] result=0x1 surface={Surface(name=null)/@0x479929b isValid=true 547759647744}
03-27 23:44:51.259 7163-7163/com.emerson.oversight D/ViewRootImpl@ebc9b08[BaiduMapActivity]: MSG_RESIZED_REPORT: frame=Rect(37, 1235 - 1403, 1641) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
03-27 23:44:51.262 7163-7163/com.emerson.oversight D/TextView: setTypeface with style : 0
03-27 23:44:51.263 7163-7163/com.emerson.oversight D/TextView: setTypeface with style : 0
03-27 23:44:51.264 7163-7163/com.emerson.oversight D/ViewRootImpl@a0e9d7f[BaiduMapActivity]: MSG_RESIZED_REPORT: frame=Rect(0, 0 - 1440, 2960) ci=Rect(0, 84 - 0, 168) vi=Rect(0, 84 - 0, 168) or=1
03-27 23:44:51.339 7163-7163/com.emerson.oversight D/ViewRootImpl@ce7e452[SelectTripActivity]: mHardwareRenderer.destroy()#1
03-27 23:44:51.359 7163-7163/com.emerson.oversight D/ViewRootImpl@ce7e452[SelectTripActivity]: Relayout returned: oldFrame=[0,0][1440,2960] newFrame=[0,0][1440,2960] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=true
03-27 23:44:54.241 7163-7163/com.emerson.oversight D/ViewRootImpl@52ebfdf[Toast]: mHardwareRenderer.destroy()#4
03-27 23:44:54.247 7163-7163/com.emerson.oversight D/ViewRootImpl@52ebfdf[Toast]: dispatchDetachedFromWindow
03-27 23:44:54.273 7163-7163/com.emerson.oversight D/InputTransport: Input channel destroyed: fd=108
03-27 23:44:54.275 7163-7163/com.emerson.oversight I/SemDesktopModeManager: unregisterListener: android.view.ViewRootImpl$3@c320e7e
03-27 23:44:59.878 7163-7168/com.emerson.oversight I/art: Do partial code cache collection, code=124KB, data=114KB
03-27 23:44:59.880 7163-7168/com.emerson.oversight I/art: After code cache collection, code=123KB, data=113KB
Increasing code cache capacity to 512KB
03-27 23:45:00.819 7163-7163/com.emerson.oversight D/ViewRootImpl@ce7e452[SelectTripActivity]: Relayout returned: oldFrame=[0,0][1440,2960] newFrame=[0,0][1440,2960] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=false
03-27 23:45:00.874 7163-7163/com.emerson.oversight I/CacheManager: TraxxEntity is null
03-27 23:45:01.533 7163-7163/com.emerson.oversight D/ViewRootImpl@ebc9b08[BaiduMapActivity]: mHardwareRenderer.destroy()#4
03-27 23:45:01.534 7163-7163/com.emerson.oversight D/ViewRootImpl@ebc9b08[BaiduMapActivity]: dispatchDetachedFromWindow
03-27 23:45:01.572 7163-7163/com.emerson.oversight D/InputTransport: Input channel destroyed: fd=113
03-27 23:45:01.575 7163-7163/com.emerson.oversight I/SemDesktopModeManager: unregisterListener: android.view.ViewRootImpl$3@7f928ab
03-27 23:45:01.618 7163-7163/com.emerson.oversight D/ViewRootImpl@a0e9d7f[BaiduMapActivity]: MSG_WINDOW_FOCUS_CHANGED 1
mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 547759640576}
03-27 23:45:01.619 7163-7163/com.emerson.oversight V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@15fb381 nm : com.emerson.oversight ic=null
03-27 23:45:01.619 7163-7163/com.emerson.oversight I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
03-27 23:45:01.631 7163-7163/com.emerson.oversight D/InputTransport: Input channel constructed: fd=104
Input channel destroyed: fd=103
03-27 23:45:01.631 7163-7163/com.emerson.oversight E/ViewRootImpl: sendUserActionEvent() returned.
Структура библиотек:
Результат ниже. Приложение работает отлично, но отображаются только линии сетки и карта не видна.
В чем может быть причина?
1 ответ
Причиной может быть несколько вариантов:
- Нет ключа API добавить в манифест
- Ключ Api привязан к неверному SHA1 или неверному имени пакета
- Использование эмулятора. Судя по моим тестам, никогда не работал на эмуляторе, но отлично работал на реальных устройствах (я держу пари на этом, так как не вижу ошибки связи с baidu в ваших логах).
Попробуйте использовать китай vpn, а потом посмотрите, загружены ли карты