Android 应用停止使用最新版本的 PhoneGap Build

标签 android angularjs phonegap-build ngresource

我使用 PhoneGap 将 AngularJS 应用程序转换为 Android 和 iOS。我需要升级到适用于 iOS 9 的最新版本的 PhoneGap,但它破坏了 Android 应用程序。

具体来说,它会阻止 ngResource 工作,因此我无法从我的服务器获取身份验证 token 。

Android 在 config.xml 首选项设置为

时工作正常
<preference name="phonegap-version" value="3.7.0" />

Android 甚至无法使用其中任何一个向服务器发送请求

<preference name="phonegap-version" value="cli-5.1.1" />
<preference name="phonegap-version" value="cli-5.2.0" />

这是我的 AngularJs 登录函数和 ngResource 工厂。

$scope.login = function () {
    AuthenticationService.get({
            'clientId':$rootScope.clientId,
            'clientSecret':$rootScope.clientSecret,
            'username':$scope.loginData.username,
            'password':$scope.loginData.password
        },
        function(data){},
        function(error){
            toastr.error('Authentication failed, please try again.');
        }
    )
    .$promise.then(function(response){
       ...
    });
};


.factory( 'AuthenticationService', function($resource, $rootScope) {
    return $resource(
        $rootScope.url+'/oauth/v2/token?client_id=:clientId&client_secret=:clientSecret&grant_type=password&username=:username&password=:password',
        {
            clientId:'@clientId',
            clientSecret:'@clientSecret',
            username:'@username',
            password:'@password'
        },
        {
            get: { method: 'JSONP', params: { callback: 'JSON_CALLBACK' }, isArray: false }
        }
    );
})

有谁知道新版本的 PhoneGap for Android 发生了什么变化可能会导致这种情况?

最佳答案

请在您的 config.xml 中添加 whitelist 插件引用

<gap:plugin name="cordova-plugin-whitelist" source="npm" />

关于Android 应用停止使用最新版本的 PhoneGap Build,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32916444/

相关文章:

javascript - adMod 与 PhoneGap 云构建

android - Phonegap 应用程序可在模拟器中运行,但不能在设备上运行

ios - Sencha/Phonegap 应用程序在 iPhone 5 中无法全屏显示

Android:GLSurfaceView 在恢复应用后是黑色的

android - 将多张图片上传到 firebase 存储

javascript - ng-bind-html 和 ng-bind-html-unsafe 不起作用?

angularjs - 复选框中的 ng-change 被触发多次,因为 ng-click 超过了它

android - 如何检查 wifi 网络是否受到 Android 应用程序中浏览器密码检查的保护?

android - 在异步任务中,构造函数是否首先运行 doInBackground?

javascript - 在 AngularJS 中将数据表移动到表