2016-12-02 2 views
0

Сбой при каждом попытке создания строки. Я хотел использовать PathOverlay, но он уже устарел. Я хочу создать строку.Android-приложение падает каждый раз, когда создает полилинию

public void drawLine(){ 
    List<GeoPoint> track = new ArrayList<>(); 
    track.add(new GeoPoint(14.4889,121.0325)); 
    track.add(new GeoPoint(14.4906,121.0353)); 

    Polyline roadOverlay = new Polyline(map.getContext()); 
    roadOverlay.setPoints(track); 
    map.getOverlays().add(roadOverlay); 
    map.invalidate(); 
} 

Gradle Консоль

Выполнение задачи ': приложение: validateSigningDebug' (уточненный чек взял 0.0 секунд) из-за: Задача не объявлял никаких результатов. : приложение: validateSigningDebug (Thread [Daemon worker Thread 2,5, main]) завершено. Прошло 0.022 сек. : приложение: packageDebug (Thread [Daemon worker Thread 2,5, main]). : app: packageDebug Выполнение задачи ': app: packageDebug' (последняя проверка прошла 0.067 секунд) из-за: Входной файл C: \ Users \ hp \ AndroidStudioProjects \ PATHS \ app \ build \ intermediates \ transforms \ dex \ debug \ folders \ 1000 \ 5 \ slice_3 \ classes.dex. : приложение: packageDebug (Thread [Daemon worker Thread 2,5, main]) завершено. Взял 6.165 секунд. : приложение: buildInfoGeneratorDebug (Thread [Daemon worker Thread 2,5, main]). : app: buildInfoGeneratorDebug Выполнение задачи ': app: buildInfoGeneratorDebug' (обновленная проверка занимает 0,0 секунд) из-за: Задача не объявила никаких выходов. : приложение: buildInfoGeneratorDebug (Thread [Daemon worker Thread 2,5, main]) завершен. Прошел 0.043 сек. : приложение: compileDebugSources (Thread [Daemon worker Thread 2,5, main]). : app: compileDebugSources Пропуск задачи ': app: compileDebugSources', поскольку он не имеет никаких действий. : приложение: compileDebugSources (Thread [Daemon worker Thread 2,5, main]) завершено. Взял 0,001 сек. : приложение: assembleDebug (Thread [Daemon worker Thread 2,5, main]). : app: assembleDebug Пропуск задачи ': app: assembleDebug', поскольку он не имеет никаких действий. : приложение: assembleDebug (Thread [Daemon worker Thread 2,5, main]) завершено. Взял 0,001 сек.

Я думаю, что это поможет? Мои плиты osmdroid находятся на моем телефоне:

$ adb shell am start -n 
"com.example.mariel.paths/com.example.mariel.paths.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER 
Client not ready yet..Connected to process 20345 on device lge-lg_x155-YL7PVWCE99999999 
V/ActivityThread: ActivityRecord{1795043f [email protected] {com.example.mariel.paths/com.example.mariel.paths.MainActivity}}: [email protected], appName=com.example.mariel.paths, pkg=com.example.mariel.paths, comp={com.example.mariel.paths/com.example.mariel.paths.MainActivity}, dir=/data/app/com.example.mariel.paths-1/base.apk 
W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable 
W/art: Suspending all threads took: 6.790ms 
I/OsmDroid: Using tile source: Mapnik 
D/Environment: getStorageVolume, volume:StorageVolume: 
        mStorageId=65537 mPath=/storage/emulated/0 mDescriptionId=17040786 
        mPrimary=true mRemovable=false mEmulated=true mMtpReserveSpace=10 
        mAllowMassStorage=false mMaxFileSize=0 mOwner=UserHandle{0} mUuid=null 
        mUserLabel=null mState=mounted 
D/Environment: getStorageVolume, volume:StorageVolume: 
        mStorageId=131073 mPath=/storage/sdcard1 mDescriptionId=17040784 
        mPrimary=false mRemovable=true mEmulated=false mMtpReserveSpace=0 
        mAllowMassStorage=true mMaxFileSize=0 mOwner=null mUuid=0000-CCCC 
        mUserLabel=KFAT1 mState=mounted 
D/Environment: getStorageVolume, volume:StorageVolume: 
        mStorageId=196609 mPath=/storage/usbotg mDescriptionId=17040787 
        mPrimary=false mRemovable=true mEmulated=false mMtpReserveSpace=0 
        mAllowMassStorage=false mMaxFileSize=0 mOwner=null mUuid=null 
        mUserLabel=null mState=removed 
I/OsmDroid: sdcard state: mounted 
D/Environment: getStorageVolume, volume:StorageVolume: 
        mStorageId=65537 mPath=/storage/emulated/0 mDescriptionId=17040786 
        mPrimary=true mRemovable=false mEmulated=true mMtpReserveSpace=10 
        mAllowMassStorage=false mMaxFileSize=0 mOwner=UserHandle{0} mUuid=null 
        mUserLabel=null mState=mounted 
D/Environment: getStorageVolume, volume:StorageVolume: 
        mStorageId=131073 mPath=/storage/sdcard1 mDescriptionId=17040784 
        mPrimary=false mRemovable=true mEmulated=false mMtpReserveSpace=0 
        mAllowMassStorage=true mMaxFileSize=0 mOwner=null mUuid=0000-CCCC 
        mUserLabel=KFAT1 mState=mounted 
D/Environment: getStorageVolume, volume:StorageVolume: 
        mStorageId=196609 mPath=/storage/usbotg mDescriptionId=17040787 
        mPrimary=false mRemovable=true mEmulated=false mMtpReserveSpace=0 
        mAllowMassStorage=false mMaxFileSize=0 mOwner=null mUuid=null 
        mUserLabel=null mState=removed 
I/OsmDroid: sdcard state: mounted 
D/Environment: getStorageVolume, volume:StorageVolume: 
        mStorageId=65537 mPath=/storage/emulated/0 mDescriptionId=17040786 
        mPrimary=true mRemovable=false mEmulated=true mMtpReserveSpace=10 
        mAllowMassStorage=false mMaxFileSize=0 mOwner=UserHandle{0} mUuid=null 
        mUserLabel=null mState=mounted 
D/Environment: getStorageVolume, volume:StorageVolume: 
        mStorageId=131073 mPath=/storage/sdcard1 mDescriptionId=17040784 
        mPrimary=false mRemovable=true mEmulated=false mMtpReserveSpace=0 
        mAllowMassStorage=true mMaxFileSize=0 mOwner=null mUuid=0000-CCCC 
        mUserLabel=KFAT1 mState=mounted 
D/Environment: getStorageVolume, volume:StorageVolume: 
        mStorageId=196609 mPath=/storage/usbotg mDescriptionId=17040787 
        mPrimary=false mRemovable=true mEmulated=false mMtpReserveSpace=0 
        mAllowMassStorage=false mMaxFileSize=0 mOwner=null mUuid=null 
        mUserLabel=null mState=removed 
I/OsmDroid: sdcard state: mounted 
I/art: Background sticky concurrent mark sweep GC freed 2440(204KB) AllocSpace objects, 0(0B) LOS objects, 17% free, 1462KB/1770KB, paused 5.950ms total 21.482ms 
D/BONUSPACK: OSRMRoadManager.getRoads:http://router.project-osrm.org/route/v1/driving/121.0325,14.4889;121.03529999999999,14.490599999999999?alternatives=false&overview=full&steps=true 
D/libc-netbsd: [getaddrinfo]: hostname=router.project-osrm.org; servname=(null); cache_mode=(null), netid=0; mark=0 
D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0 
D/ActivityThread: ACT-LAUNCH_ACTIVITY handled : 0/ActivityRecord{1795043f [email protected] {com.example.mariel.paths/com.example.mariel.paths.MainActivity}} 
D/ActivityThread: ACT-PAUSE_ACTIVITY_FINISHING handled : 0/[email protected] 
W/art: Suspending all threads took: 7.461ms 
D/ActivityThread: ACT-DESTROY_ACTIVITY handled : 1/[email protected] 
W/art: Suspending all threads took: 7.023ms 
+0

Если ваше приложение выходит из строя, отправьте трассировку стека – 0xDEADC0DE

+0

проверьте, не отображается ли карта * null * – kId

+0

Я не знаю, где найти трассировку стека, но я редактировал ее для просмотра сообщения на консоли градиента. Я запускаю программу на своем телефоне Android. Если я удаляю drawLine(), он работает и не имеет ошибки. – Temmie

ответ

1

попытаться удалить map.invalidate(); .. Я думаю, его не нужно в onCreate, поскольку представление будет сделано после того, как onCreate существует.

Смежные вопросы