环境
- 反应原生 0.60
发生什么了:
我有一个组件,它使用<ImageBackground>
.
如果我将应用程序捆绑为debugRelease,它就像一个魅力,并且显示每个按钮的所有图像。如果我将应用程序捆绑为releaseBundle,则缺少 7 个图像中的 4 个(所有时间都是相同的图像)。
我试过的
所以按钮 1 不工作,按钮 2 - 4 工作,按钮 5 - 7 甚至不工作。可以肯定的是,图像文件没有损坏,我用新名称复制了按钮 2 的图像,并用这个替换了图像 1。无论如何,图像都没有显示!
所以我启动了 Android Studio 并在 debug-APK 和 release-APS 中打开了 apk 来检查里面的文件。结果如下:
您是否有任何线索,为什么只有一些图像文件没有以正确的方式捆绑到 Release-APK 中(即使该文件spenden.jpg
是上述工作kontakt.jpg
文件的副本)?
这是我实现它的方式:
...
const getHomeButtonList = (data, dropdowns) => [
{
id: 'offer',
bgImage: { uri: 'erwin' },
btnText: 'ANGEBOTE \n DER SKG',
navigateTo: 'Offer',
},
{
id: 'contact',
bgImage: { uri: 'kontakt' },
btnText: 'KONTAKTE',
navigateTo: 'Contact',
data: {
data,
dropdowns,
},
},
{
id: 'videos',
bgImage: { uri: 'videos' },
btnText: 'VIDEOS',
navigateTo: 'VideoList',
},
{
id: 'innovationen',
bgImage: { uri: 'innovationen' },
btnText: 'INNOVATION IN MEDIZIN UND \nGESUNDHEITSWESEN',
navigateTo: 'CategorizedPage',
data: {
headerTitle: 'Innovationen',
headerImage: 'innovationen',
data: data.innovations,
},
},
{
id: 'nebenwirkungen',
bgImage: { uri: 'nebenwirkungen' },
btnText: 'HILFE BEI NEBENWIRKUNGEN',
navigateTo: 'CategorizedPage',
data: {
headerTitle: 'Nebenwirkungen',
headerImage: 'nebenwirkungen',
data: data.sideeffects,
},
},
{
id: 'beratung',
bgImage: { uri: 'consultation' },
btnText: 'BERATUNG UND BEGLEITUNG',
navigateTo: 'CategorizedPage',
data: {
headerTitle: 'Beratung',
headerImage: 'consultation',
data: data.advice,
},
},
{
id: 'spenden',
bgImage: { uri: 'spenden' },
btnText: 'SPENDEN',
navigateTo: 'Browser',
navigateUrl: url.donateUrl,
},
];
...
Grid = (props) => {
const { columns, orientation } = this.state;
return (
<FlatList
data={props}
key={orientation}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<View style={(orientation === 'portrait') ? [
styles.btn,
styles.btnFirst] : [landscape.btn, styles.btnFirst]}
>
<TouchableOpacity
style={[styles.touchBtn, styles[item.id]]}
onPress={() => this.pressImageButton(item)}
>
<ImageBackground
resizeMode="cover"
style={styles.imageBackground}
source={item.bgImage}
>
<View style={styles.imageOverlay} />
<Text style={[styles.btnText]}>
{item.btnText}
</Text>
</ImageBackground>
</TouchableOpacity>
</View>
)}
numColumns={columns}
/>
);
};
...
<View style={(orientation === 'portrait')
? styles.btnContainer
: landscape.btnContainer}
>
{this.Grid(getHomeButtonList(data, dropdowns))}
</View>