2013-09-08 12 views
11

私のphonegapアプリケーションに格納用にAndroid File Systemにアクセスする際に問題があります。私は検索し、多くの非私の状況の解決策を見つけました!Phonegap Android LocalFileSystemが定義されていません

私は解雇され、点検され、解雇される必要があることを知っています。したがって、phonegap.jsは完全にロードされています!

私は、ファイルのアクセス許可を要求し、私のマニフェストと設定ファイルに機能を持っていると思います。ここで彼らは、次のとおりです。

のconfig.xml:

<feature name="http://api.phonegap.com/1.0/device" /> 
    <feature name="http://api.phonegap.com/1.0/battery"/> 
    <feature name="http://api.phonegap.com/1.0/camera"/> 
    <feature name="http://api.phonegap.com/1.0/contacts"/> 
    <feature name="http://api.phonegap.com/1.0/file"/> 
    <feature name="http://api.phonegap.com/1.0/geolocation"/> 
    <feature name="http://api.phonegap.com/1.0/media"/> 
    <feature name="http://api.phonegap.com/1.0/network"/> 
    <feature name="http://api.phonegap.com/1.0/notification"/> 
    <preference name="permissions" value="none" /> 
    <preference name="orientation" value="default" /> 
    <preference name="target-device" value="universal" /> 
    <preference name="fullscreen" value="true" /> 
    <preference name="webviewbounce" value="true" /> 
    <preference name="prerendered-icon" value="true" /> 
    <preference name="stay-in-webview" value="false" /> 
    <preference name="ios-statusbarstyle" value="black-opaque" /> 
    <preference name="detect-data-types" value="true" /> 
    <preference name="exit-on-suspend" value="false" /> 
    <preference name="show-splash-screen-spinner" value="true" /> 
    <preference name="auto-hide-splash-screen" value="true" /> 
    <preference name="disable-cursor" value="false" /> 
    <preference name="android-minSdkVersion" value="7" /> 
    <preference name="android-installLocation" value="auto" /> 
    <icon src="icon.png" /> 
    <icon gap:density="ldpi" gap:platform="android" src="res/icon/android/icon-36-ldpi.png" /> 
    <icon gap:density="mdpi" gap:platform="android" src="res/icon/android/icon-48-mdpi.png" /> 
    <icon gap:density="hdpi" gap:platform="android" src="res/icon/android/icon-72-hdpi.png" /> 
    <icon gap:density="xhdpi" gap:platform="android" src="res/icon/android/icon-96-xhdpi.png" /> 
    <access origin="*" /> 
    <content src="index.html" /> 
</widget> 

のAndroidManifest.xml:

<?xml version='1.0' encoding='utf-8'?> 
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="1.0.0" android:windowSoftInputMode="adjustPan" package="com.pakhshyaran.kara" xmlns:android="http://schemas.android.com/apk/res/android"> 
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.VIBRATE" /> 
    <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_LOCATION_EXTRA_COMMANDS" /> 
    <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
    <uses-permission android:name="android.permission.RECEIVE_SMS" /> 
    <uses-permission android:name="android.permission.RECORD_AUDIO" /> 
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> 
    <uses-permission android:name="android.permission.READ_CONTACTS" /> 
    <uses-permission android:name="android.permission.WRITE_CONTACTS" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.GET_ACCOUNTS" /> 
    <uses-permission android:name="android.permission.BROADCAST_STICKY" /> 
    <uses-permission android:name="android.permission." /> 
    <application android:debuggable="true" android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name"> 
     <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/app_name" android:name="Kara" android:theme="@android:style/Theme.Black.NoTitleBar"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 
    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="18" /> 
</manifest> 

、ここでは私のコードの一部を投げるエラーです:

$(document).ready(function() { 
    document.addEventListener("deviceready", onDeviceReady, false); 
}); 
function onDeviceReady() { 
    window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function (fileSystem) { //throws the 'Uncaught ReferenceError: LocalFileSystem is not defined' error 
     fileSystem = fileSystem; 
    }, function (evt) { 
     alert(evt.target.error.code); 
    }); 
} 

しかし、私私は何の考えも持っていない理由でエラーを取得する!あなたの考えを教えてください。私はとても感謝しています。

PS:私はphonegap 3.0を使用しています!

答えて

19

プロジェクトをビルドするのにphonegap cliを使用していますか?その後、プロジェクトにFileプラグインを追加していない可能性があります。​​3210とAndroidManifiest.xmlの設定のほかに、プラグインのコードが必要です。あなたとあなたのプロジェクトに追加することができます:ドキュメント内のページの

$ phonegap plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git 

チェックトップ:http://docs.phonegap.com/en/3.0.0/cordova_file_file.md.html#LocalFileSystem

またwindow.LocalFileSystemが実際に定義されているかどうかを確認するために、ファイルandroid/assets/www/cordova_plugins.jsを確認することができます。次のようなものを探してください:

{ 
    "file": "plugins/org.apache.cordova.core.file/www/FileSystem.js", 
    "id": "org.apache.cordova.core.file.FileSystem", 
    "clobbers": [ 
     "window.FileSystem" 
    ] 
}, 
+2

ご返信ありがとうございます。私はプラグインを追加する必要があることを知らなかった。私はコマンドを実行し、それは実行された。 cordova_plugins.jsには何も起こりません。私が知るべきことが他にありますか? – Hosein

+2

@Hoseinプラグインを追加すると実際にも設定が追加されます。もう一度ビルドしてみてください:cordova build android – davidlgj

+0

ありがとうございます。それは少し苦難で解決されました。 – Hosein

関連する問題