在为我的 React Native 项目制作发布版本时出现此错误:
Expiring Daemon because JVM heap space is exhausted
> Task :app:transformDexArchiveWithDexMergerForRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformDexArchiveWithDexMergerForRelease'.
> java.lang.OutOfMemoryError (no error message)
Run Code Online (Sandbox Code Playgroud)
做了一些研究并进行了一些更改,如下所示:
添加 android:largeHeap="true"到 AndroidManifest.xml 中的应用程序标签
添加
dexOptions {
javaMaxHeapSize "4g"
}
Run Code Online (Sandbox Code Playgroud)
在 android/app/build.gradle 文件中。
将以下代码添加到 gradle.properties
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=4096m -XX:+HeapDumpOnOutOfMemoryError
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
Run Code Online (Sandbox Code Playgroud)
我仍然无法摆脱这个错误。任何永久的方法来摆脱这个错误,它是如何引起的?
我试图使用 REST 框架制作 API 以将文件上传到服务器,我的代码如下。
如果您有任何其他简单的方法来做同样的事情,请发布您的代码。
模型.py
from django.db import models
# Create your models here.
class FileUploader(models.Model):
file = models.FileField()
name = models.CharField(max_length=100) #name is filename without extension
version = models.IntegerField(default=0)
upload_date = models.DateTimeField(auto_now=True, db_index=True)
owner = models.ForeignKey('auth.User', related_name='uploaded_files')
size = models.IntegerField(default=0)
def __str__(self):
return self.name
Run Code Online (Sandbox Code Playgroud)
序列化程序.py
class FileUploaderSerializer(serializers.ModelSerializer):
class Meta:
model=FileUploader
fields='__all__'
read_only_fields = '__all__'
def validate(self, validated_data):
validated_data['owner'] = self.context['request'].user
validated_data['name'] = os.path.splitext(validated_data['file'].name)[0]
validated_data['size'] = validated_data['file'].size
return validated_data
def create(self,validated_data):
return FileUploader.objects.create(**validated_data)
Run Code Online (Sandbox Code Playgroud)
视图.py
class FileUploaderViewSet(viewsets.ModelViewSet):
serializer_class = …Run Code Online (Sandbox Code Playgroud) 我有一个带有 url 的 webview(例如付款处理页面)。加载 url 后,某些 api 调用就完成了,我想知道如何从该特定 url 的内部 api 调用中获取数据。
它不像网页和本机代码之间的通信。(window.ReactNativeWebView.postMessage或onMessage) 我需要来自网页的内部 api 调用响应数据。
我正在研究一个 firebase 项目,为了显示时间和实体,我得到的是时间戳。我正在做一个 React Native 项目。如何将接收到的时间戳转换为格式正确的日期。这是时间戳:
我有这个时间可用this.props.time,所以我尝试过,this.props.time.toDate()但我得到的是一个错误。
Invariant Violation:Objects are not valid as a React child(found: Tue Nov 26 2019 11:51:58 GMT+05:30(Indian Standard Time))
javascript firebase react-native google-cloud-firestore redux-firestore
我是颤振的菜鸟,现在正在试验颤振。我试图实现一个闪屏。我的要求:
我有一个很大的“文本”字段,当我在卡片部分中显示它时,我需要在结尾处修剪它并仅显示特定长度。
例如:如果文本是:
Lorem Ipsum只是印刷和排版行业的伪文本。自1500年代以来,Lorem Ipsum一直是行业的标准伪文本,当时一位不知名的打印机拿来一个厨房,然后将其打乱成麦
我需要缩短长度以获取类似以下内容的文本:
Lorem Ipsum只是假文字...
突然间,当我尝试向 Podfile 添加新的 Pod 并尝试安装它们时,这个过程变得无限!这是我的 Podfile:
# Podfile content
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
target 'MyProject' do
# React Native
rn_path = '../node_modules/react-native'
rn_maps_path = '../node_modules/react-native-maps'
pod 'yoga', :path => "#{rn_path}/ReactCommon/yoga"
pod 'RNSVG', :path => '../node_modules/react-native-svg'
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
pod 'React', path: "#{rn_path}", :subspecs => [
'Core',
'CxxBridge',
'RCTActionSheet',
'RCTAnimation',
'RCTGeolocation',
'RCTImage',
'RCTLinkingIOS',
'RCTNetwork',
'RCTSettings',
'RCTText',
'RCTVibration',
'RCTWebSocket',
'DevSupport'
]
pod 'DoubleConversion', :podspec => "#{rn_path}/third-party-podspecs/DoubleConversion.podspec"
pod 'glog', :podspec => "#{rn_path}/third-party-podspecs/glog.podspec"
pod 'Folly', :podspec => "#{rn_path}/third-party-podspecs/Folly.podspec"
# Required by …Run Code Online (Sandbox Code Playgroud) 我制作了一个聊天应用程序,并使用平面列表来呈现消息。但问题是每次加载页面时都尝试滚动到屏幕末尾,但失败了。我尝试过反转道具,但什么也没发生,只是列表反转了。
甚至用 ref 让它自动滚动到底部,但什么也没发生。
<FlatList
ref="flatList"
onContentSizeChange={() =>
this.refs.flatList.scrollToEnd()}
contentContainerStyle={{
marginBottom:
verticalScale(200)
}}
style={styles.list}
data={this.state.messages}
/>
Run Code Online (Sandbox Code Playgroud)
如何让它在渲染时滚动到屏幕底部或滚动到消息的最后一个索引?
(更新)
<Content/>这是我使用的属于 native-base 的组件的问题。删除并用 a 替换它后,<View/>它工作得很好。此外,对于基于聊天的应用程序,inverted其中的道具Flatlist是以正确的方式实现的。
我在下面的答案中添加了我设法滚动的方式。如果您只想让应用程序显示列表中的最后一项并保留在那里,您可以使用inverted
react-native ×6
javascript ×2
android ×1
cocoapods ×1
django ×1
firebase ×1
flutter ×1
ios ×1
java ×1
python ×1