![](/img/trans.png)
[英]Appcelerator Titanium 3 Android emulator environment errors
[英]Appcelerator Titanium 5.5.1 Android Geolocation Module Gives checkSelfPermission and requestPermissions Errors
我试图以一种非常简单的方式调用地理定位模块,但遇到了错误。 我正在测试一款物理手机,这是运行Android 4.4.2的三星Galaxy S3。 这是代码,它是在我的页面的控制器.js中运行的:
function getGPSCoordinates() {
if (Ti.Geolocation.locationServicesEnabled) {
Ti.Geolocation.purpose = 'Corollate photos with store location';
Ti.Geolocation.preferredProvider = Ti.Geolocation.PROVIDER_GPS;
Ti.Geolocation.getCurrentPosition(function(e) {
if (e.error == true)
console.error(e.error);
else
console.warn(e.coords);
});
}
}
if (Ti.Geolocation.locationServicesEnabled)
getGPSCoordinates();
else {
Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE, function(e) {
getGPSCoordinates();
});
}
...以下是日志中返回的错误:
[INFO] : dalvikvm: Could not find method android.app.Activity.checkSelfPermission, referenced from method ti.modules.titanium.geolocation.GeolocationModule.hasLocationPermissions
[WARN] : dalvikvm: VFY: unable to resolve virtual method 27: Landroid/app/Activity;.checkSelfPermission (Ljava/lang/String;)I
[INFO] : dalvikvm: Could not find method android.app.Activity.requestPermissions, referenced from method ti.modules.titanium.geolocation.GeolocationModule.requestLocationPermissions
[WARN] : dalvikvm: VFY: unable to resolve virtual method 74: Landroid/app/Activity;.requestPermissions ([Ljava/lang/String;I)V
我做了一个干净的构建,问题仍然存在。 我还查看了build / android / androidmanifest.xml,可以看到正确的权限被自动添加到清单中:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>
我的开发环境的相关部分如下:
Operating System
Name = Mac OS X
Version = 10.11.6
Architecture = 64bit
# CPUs = 8
Memory = 16.0GB
Node.js
Node.js Version = 0.12.7
npm Version = 2.11.3
Appcelerator CLI
Installer = 4.2.7
Core Package = 5.5.1
Titanium CLI
CLI Version = 5.0.9
node-appc Version = 0.2.31
Titanium SDKs
5.5.1.GA
Version = 5.5.1
Install Location = /Users/xxxxxxxxxx/Library/Application Support/Titanium/mobilesdk/osx/5.5.1.GA
Platforms = android, mobileweb, iphone
git Hash = b18727f
git Timestamp = 09/27/16 05:38
node-appc Version = 0.2.36
Mac OS X
Command Line Tools = installed
Intel® Hardware Accelerated Execution Manager (HAXM)
Installed = yes
Memory Limit = 2 GB
Java Development Kit
Version = 1.8.0_102
Java Home = /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home
Android SDK
Android Executable = /Users/xxxxxxxxxx/Library/Android/sdk/tools/android
ADB Executable = /Users/xxxxxxxxxx/Library/Android/sdk/platform-tools/adb
SDK Path = /Users/xxxxxxxxxx/Library/Android/sdk
Android NDK
NDK Path = not found
NDK Version = not found
Android Platforms
1) android-23
Name = Android 6.0
API Level = 23
Revision = 3
Skins = HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800, WVGA854, WXGA720, WXGA800, WXGA800-7in
ABIs = x86
Path = /Users/xxxxxxxxxx/Library/Android/sdk/platforms/android-23
Android Add-Ons
None
Connected Android Devices
SPH-L710
ID = 8c1af53b
State = device
SDK Version = 4.4.2 (android-19)
ABIs = armeabi-v7a, armeabi
如果有什么我应该做的不同,请告诉我。 谢谢!
您的应用是否在设备上拥有位置权限? 检查您的设置并为应用程序启用它们并查看此( https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Geolocation-method-requestLocationPermissions )以了解如何确保您拥有权限在请求位置之前。
另外,还有另一个有类似报告的帖子可能会给你一些见解。 ( Appcelerator无法找到方法android.app.Activity.checkSelfPermission )
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.