Comments (2)
研究了2天吧,最终解决方法就是在 root工程的gradle.properties添加:
systemProp.javax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
原因:
我觉得是 gradle 或者 agp 的bug,DocumentBuilderFactory#newInstance() 在找底层实现的时候,出现了同一个方法返回了两种实现一个是 com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl 另一个是 org.apache.xerces.jaxp.DocumentBuilderFactoryImpl 然后调用到 NodeUtils#adoptNode(Document document, Node node) 时 document和node来自不同的实现,adoptNode 就直接返回了NULL,后面就空指针了。
解决:
DocumentBuilderFactory#newInstance() 再向下走创建实例的过程中有一步是查看是否设置了SystemProperty
try {
factoryClassName = SecuritySupport.getSystemProperty(factoryId);
if (factoryClassName != null) {
dPrint(() -> {
return "found system property, value=" + factoryClassName;
});
return newInstance(type, factoryClassName, (ClassLoader)null, true);
}
} catch (SecurityException var9) {
if (debug) {
var9.printStackTrace();
}
}
直接通过gradle.properties定义下这个property,这样获取的实现就一致了
求助:
DocumentBuilderFactory#newInstance() 后面的实例化 DocumentBuilderFactory 的过程中有使用ServiceLoader,
private static <T> T findServiceProvider(final Class<T> type) {
try {
return AccessController.doPrivileged(new PrivilegedAction<T>() {
public T run() {
ServiceLoader<T> serviceLoader = ServiceLoader.load(type);
Iterator<T> iterator = serviceLoader.iterator();
return iterator.hasNext() ? iterator.next() : null;
}
});
} catch (ServiceConfigurationError var4) {
RuntimeException x = new RuntimeException("Provider for " + type + " cannot be created", var4);
FactoryConfigurationError error = new FactoryConfigurationError(x, x.getMessage());
throw error;
}
}
就是这个地方,出现了本插件使用流程中实例化查不到实现,其它情况能查到,哪位知道原因的话,烦请回复下。
from micromodule.
Related Issues (16)
- 在新建activity的时候能否指定路径? HOT 3
- pins工程之间怎么通信? HOT 2
- 能来个中文文档么 HOT 2
- MicroMoudle生成的R文件缺少mipmap资源引用 HOT 2
- Execution failed for task ':application:mergeDebugResources'. > String index out of range: -1 HOT 1
- 运行提示找不到Activity Could not identify launch activity: Default Activity not found HOT 2
- 如何为某个 flavor 排除某个 p 工程 HOT 1
- 能否和fat-aar插件结合用于打aar
- microModuleReferenceMap's mulit initialization will lost most of dependencies info when multi module apply plugins HOT 2
- 使用productFlavors的时候应该哪里创建文件夹 HOT 2
- 字符串比较使用== HOT 1
- 支持kotlin? HOT 2
- 插件源码添加MicroModule资源过程重复了? HOT 8
- Cannot get property 'microModuleDir' on null object HOT 3
- R.java引用不到 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from micromodule.