Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android not working #205

Closed
chenyulun opened this issue Jan 6, 2023 · 8 comments
Closed

android not working #205

chenyulun opened this issue Jan 6, 2023 · 8 comments

Comments

@chenyulun
Copy link

chenyulun commented Jan 6, 2023

Hi ! Thank you for reporting an issue, but we would like to remind you, we have a trouble shooting page in our wiki.
You may want to take a look on that page or find issues tagged "trouble shooting" :p

  • please provide the version of installed library and RN project.
  • a sample code snippet/repository is very helpful to spotting the problem.
  • issues which have been tagged as 'needs feedback', will be closed after 2 weeks if receive no feedbacks.
  • issues lack of detailed information will be closed without any feedback

package.json

"dependencies": {
    "react": "17.0.1",
    "react-native": "0.64.4",
    "react-native-blob-util": "0.17.1"
  }
➜  rnTest git:(main) ✗ npx react-native --version
5.0.1
➜  rnTest git:(main) ✗ npx react-native config

output

{
"react-native-blob-util": {
      "root": "/Users/username/learn/rntest/rnTest/node_modules/react-native-blob-util",
      "name": "react-native-blob-util",
      "platforms": {
        "ios": {
          "sourceDir": "/Users/username/learn/rntest/rnTest/node_modules/react-native-blob-util/ios",
          "folder": "/Users/username/learn/rntest/rnTest/node_modules/react-native-blob-util",
          "pbxprojPath": "/Users/username/learn/rntest/rnTest/node_modules/react-native-blob-util/ios/ReactNativeBlobUtil.xcodeproj/project.pbxproj",
          "podfile": null,
          "podspecPath": "/Users/username/learn/rntest/rnTest/node_modules/react-native-blob-util/react-native-blob-util.podspec",
          "projectPath": "/Users/username/learn/rntest/rnTest/node_modules/react-native-blob-util/ios/ReactNativeBlobUtil.xcodeproj",
          "projectName": "ReactNativeBlobUtil.xcodeproj",
          "libraryFolder": "Libraries",
          "sharedLibraries": [],
          "plist": [],
          "scriptPhases": [],
          "configurations": []
        },
        "android": null
      },
      "assets": [],
      "hooks": {},
      "params": []
}

android return null

@chenyulun
Copy link
Author

chenyulun commented Jan 6, 2023

all .java files no has public class XXXX implements ReactPackage

function getPackageClassName(folder) {
  const files = _glob().default.sync('**/+(*.java|*.kt)', {
    cwd: folder
  });

  const packages = files.map(filePath => _fs().default.readFileSync(_path().default.join(folder, filePath), 'utf8')).map(matchClassName).filter(match => match); // @ts-ignore

  return packages.length ? packages[0][1] : null;
}

function matchClassName(file) {
  return file.match(/class\s+(\w+[^(\s]*)[\s\w():]*(\s+implements\s+|:)[\s\w():,]*[^{]*ReactPackage/);
}

@chenyulun
Copy link
Author

Can't identify 'public class ReactNativeBlobUtilPackage extends TurboReactPackage {'

@react-native-community/[email protected]
node_modules/@react-native-community/cli-platform-android/build/config/findPackageClassName.js

@chenyulun
Copy link
Author

The @react-native-community/[email protected] attached to RN 6.4.4 will not parse properly

@chenyulun
Copy link
Author

woking in RN 0.65.3,
@react-native-community/[email protected]
@react-native-community/[email protected]
node_modules/@react-native-community/cli-platform-android/build/config/findPackageClassName.js

function matchClassName(file) {
  const nativeModuleMatch = file.match(/class\s+(\w+[^(\s]*)[\s\w():]*(\s+implements\s+|:)[\s\w():,]*[^{]*ReactPackage/); // We first check for implementation of ReactPackage to find native
  // modules and then for subclasses of TurboReactPackage to find turbo modules.

  if (nativeModuleMatch) {
    return nativeModuleMatch;
  } else {
    return file.match(/class\s+(\w+[^(\s]*)[\s\w():]*(\s+extends\s+|:)[\s\w():,]*[^{]*TurboReactPackage/);
  }
}

@chenyulun
Copy link
Author

fix :
react-native.config.js

const path = require('path');
module.exports = {
  dependencies: {
    'react-native-blob-util': {
      platforms: {
        android: {
          sourceDir: path.resolve(
            __dirname,
            'node_modules/react-native-blob-util/android',
          ),
          folder: path.resolve(
            __dirname,
            'node_modules/react-native-blob-util',
          ),
          packageImportPath:
            'import com.ReactNativeBlobUtil.ReactNativeBlobUtilPackage;',
          packageInstance: 'new ReactNativeBlobUtilPackage()',
          buildTypes: [],
        },
      },
    },
  },
}

@RonRadtke
Copy link
Owner

So it's working with 0.65 but not with 0.64?
That's technically ok since we dropped support for 0.64 with 0.17.0.
But if you got it to work that would of course be awesome!

@kawsar6848
Copy link

I am getting this error from play console:
React Native Version: 0.64
sdk:31
java.lang.SecurityException

Exception java.lang.SecurityException: Unsupported path /storage/emulated/0/Download
at android.os.Parcel.createExceptionOrNull (Parcel.java:2376)
at android.os.Parcel.createException (Parcel.java:2360)
at android.os.Parcel.readException (Parcel.java:2343)
at android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:190)
at android.database.DatabaseUtils.readExceptionFromParcel (DatabaseUtils.java:142)
at android.content.ContentProviderProxy.insert (ContentProviderProxy.java:549)
at android.content.ContentResolver.insert (ContentResolver.java:2177)
at android.content.ContentResolver.insert (ContentResolver.java:2138)
at android.app.DownloadManager.enqueue (DownloadManager.java:1625)
at com.ReactNativeBlobUtil.ReactNativeBlobUtilReq.run (ReactNativeBlobUtilReq.java)
at com.ReactNativeBlobUtil.ReactNativeBlobUtil.fetchBlob (ReactNativeBlobUtil.java)
at java.lang.reflect.Method.invoke (Method.java)
at com.facebook.react.bridge.JavaMethodWrapper.invoke (JavaMethodWrapper.java)
at com.facebook.react.bridge.JavaModuleWrapper.invoke (JavaModuleWrapper.java)
at com.facebook.react.bridge.queue.NativeRunnable.run (NativeRunnable.java)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage (MessageQueueThreadHandler.java)
at android.os.Looper.loop (Looper.java:236)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run (MessageQueueThreadImpl.java)
at java.lang.Thread.run (Thread.java:923)

How to solve this problem

@EHRdev
Copy link

EHRdev commented Oct 13, 2023

fix : react-native.config.js

const path = require('path');
module.exports = {
  dependencies: {
    'react-native-blob-util': {
      platforms: {
        android: {
          sourceDir: path.resolve(
            __dirname,
            'node_modules/react-native-blob-util/android',
          ),
          folder: path.resolve(
            __dirname,
            'node_modules/react-native-blob-util',
          ),
          packageImportPath:
            'import com.ReactNativeBlobUtil.ReactNativeBlobUtilPackage;',
          packageInstance: 'new ReactNativeBlobUtilPackage()',
          buildTypes: [],
        },
      },
    },
  },
}

thank you master, it worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants