最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - expo manged workflow with custom libarary not auto linking correctly - Stack Overflow

programmeradmin3浏览0评论

I am currntly starting to rewrite my react native bare app in expo now that it supports custom libraries. I developed a library for android as I could not find a soution for that, it works fine with my bare workflow project.

In expo, while buiding locally (or EAS), the android PackageList.java throws an error, cannot find symbol import com.example.mypackage;

E:\app-path\android\app\build\generated\autolinking\src\main\java\com\facebook\react\PackageList.java:14: error: cannot find symbol
import com.example.MyPackage;
                   ^
  symbol:   class MyPackage
  location: package com.example
E:\app-path\android\app\build\generated\autolinking\src\main\java\com\facebook\react\PackageList.java:72: error: cannot find symbol
      new MyPackage(),
          ^
  symbol:   class MyPackage
  location: class PackageList
2 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

Ive tried to resolve this by adding to my library;

"expo": {
"plugins": [
  "./plugin.js"
 ]
},

to my package.json and the plugin file as follows;

const { withAndroidManifest } = require('@expo/config-plugins');

const withPlugin = (config) => {
  return withAndroidManifest(config, (config) => {
    const manifest = config.modResults;
    
    if (!manifest['uses-permission']) {
      manifest['uses-permission'] = [];
    }

    manifest['uses-permission'].push(
      { $: { 'android:name': 'android.permission.USB_PERMISSION' } },
      { $: { 'android:name': 'android.permission.INTERNET' } },
      { $: { 'android:name': 'android.permission.ACCESS_NETWORK_STATE' } }
    );

    return config;
  });
};

module.exports = withPlugin;

And applied my app.json i added the plugin like so,

"plugins": [
      "expo-router",
      "@mypackage/mypackage",
      [
        "expo-splash-screen",
        {
          "image": "./assets/images/splash-icon.png",
          "imageWidth": 200,
          "resizeMode": "contain",
          "backgroundColor": "#ffffff"
        }
      ]
    ],

However, with this, the plugins resolution fails.

发布评论

评论列表(0)

  1. 暂无评论